diff --git a/research/p104-tiered-ceiling/CHECK.txt b/research/p104-tiered-ceiling/CHECK.txt new file mode 100644 index 0000000000..1cb8fb1a78 --- /dev/null +++ b/research/p104-tiered-ceiling/CHECK.txt @@ -0,0 +1,257 @@ +CHECK.txt: fresh build of the import closure of Nov15/CongestionNativeJ.lean, Nov15/JunkLawACeiling.lean and Nov15/CongestionNativeZ*.lean (66 modules) +Toolchain leanprover/lean4:v4.33.0-rc1; Mathlib 55b7917b472489c7c56a0fa6393af05cfd536599 (an existing build of that commit, no download). + +METHOD + * Every module compiled ALONE in dependency order, one lean process at a time: lean -j1 -o out/Nov15/X.olean Nov15/X.lean from lean/, under a 3.5 GB (3,500,000 KB) RSS watcher. + * A fresh, initially empty output directory was FIRST on the module search path, so imports resolved to oleans built in this run, then the pinned Mathlib packages. + * Axioms: the #print axioms lines inside the files. No Lean.ofReduceBool, no sorryAx, no 'declaration uses sorry' in any log. + * lake build was not run (it would download Mathlib). + +EXCEPTION (one module of 66) + * CongestionI3Cfg (unchanged since #7656) was killed by the 3.5 GB guard at peak 3422 MB and again at 3444 MB (rc=143, partial run, no olean from this run). For the 64 modules built after it, its olean from the earlier build of the same source was placed in the output directory. The other 65 modules were compiled fresh with rc=0. + +COMPILE TABLE (module, rc, wall, peak RSS, errors, sorry warnings), build order +CongestionI3Data rc=0 time=10s peak=1344MB errors=0 sorry=0 +CongestionI3Cfg rc=143 (killed by the 3.5 GB guard, twice; see EXCEPTION) +CongestionI3Mu rc=0 time=3s peak=1305MB errors=0 sorry=0 +NumCertK rc=0 time=20s peak=2974MB errors=0 sorry=0 +CongestionI3NumA rc=0 time=20s peak=3139MB errors=0 sorry=0 +CongestionI3NumC1 rc=0 time=20s peak=3123MB errors=0 sorry=0 +CongestionI3NumC2 rc=0 time=19s peak=3072MB errors=0 sorry=0 +CongestionI3NumC3 rc=0 time=20s peak=3072MB errors=0 sorry=0 +CongestionI3NumC4 rc=0 time=12s peak=2919MB errors=0 sorry=0 +WholeFloorCoverData1 rc=0 time=20s peak=3139MB errors=0 sorry=0 +WholeFloorCoverData rc=0 time=29s peak=3328MB errors=0 sorry=0 +CallerCost rc=0 time=11s peak=2933MB errors=0 sorry=0 +JointCeiling rc=0 time=10s peak=2955MB errors=0 sorry=0 +WholeFloorCover rc=0 time=6s peak=2858MB errors=0 sorry=0 +CongestionI3 rc=0 time=15s peak=2982MB errors=0 sorry=0 +TokenCancel rc=0 time=6s peak=1644MB errors=0 sorry=0 +FrameSep rc=0 time=4s peak=1501MB errors=0 sorry=0 +JunkLB2 rc=0 time=10s peak=2461MB errors=0 sorry=0 +RelaySandwich rc=0 time=5s peak=2313MB errors=0 sorry=0 +RankLaw rc=0 time=7s peak=2041MB errors=0 sorry=0 +RankLawC rc=0 time=5s peak=1985MB errors=0 sorry=0 +SwapWord rc=0 time=5s peak=1997MB errors=0 sorry=0 +SwapNull rc=0 time=7s peak=2451MB errors=0 sorry=0 +FibreK rc=0 time=9s peak=2938MB errors=0 sorry=0 +WordDuality rc=0 time=8s peak=2892MB errors=0 sorry=0 +CongestionI3DualAlg rc=0 time=6s peak=2872MB errors=0 sorry=0 +CongestionI3DualConst rc=0 time=3s peak=1136MB errors=0 sorry=0 +CongestionI3DualSig rc=0 time=7s peak=2925MB errors=0 sorry=0 +CongestionI3DualData rc=0 time=5s peak=2269MB errors=0 sorry=0 +CongestionI3DualNumC rc=0 time=13s peak=2939MB errors=0 sorry=0 +CongestionI3DualCertC0 rc=0 time=8s peak=3159MB errors=0 sorry=0 +CongestionI3DualCertC1 rc=0 time=7s peak=3156MB errors=0 sorry=0 +CongestionI3DualCertC2 rc=0 time=7s peak=3148MB errors=0 sorry=0 +CongestionI3DualCertC3 rc=0 time=7s peak=3145MB errors=0 sorry=0 +CongestionNativeTab rc=0 time=3s peak=1280MB errors=0 sorry=0 +CongestionNative rc=0 time=11s peak=2962MB errors=0 sorry=0 +CongestionNativeJDefs rc=0 time=4s peak=2293MB errors=0 sorry=0 +CongestionNativeJSig0 rc=0 time=7s peak=3156MB errors=0 sorry=0 +CongestionNativeJSig1 rc=0 time=7s peak=3155MB errors=0 sorry=0 +CongestionNativeJSig2 rc=0 time=7s peak=3156MB errors=0 sorry=0 +CongestionNativeJPt0 rc=0 time=7s peak=2871MB errors=0 sorry=0 +CongestionNativeJPt1 rc=0 time=7s peak=2869MB errors=0 sorry=0 +CongestionNativeJPt2 rc=0 time=7s peak=2868MB errors=0 sorry=0 +CongestionNativeJD rc=0 time=8s peak=2861MB errors=0 sorry=0 +CongestionNativeJUnit rc=0 time=5s peak=2539MB errors=0 sorry=0 +CongestionNativeJ rc=0 time=8s peak=2931MB errors=0 sorry=0 +JunkLawA rc=0 time=7s peak=2805MB errors=0 sorry=0 +CongestionNativeNDefs rc=0 time=3s peak=1332MB errors=0 sorry=0 +CongestionNativeNSig0 rc=0 time=7s peak=3155MB errors=0 sorry=0 +CongestionNativeNSig1 rc=0 time=7s peak=3157MB errors=0 sorry=0 +CongestionNativeNSig2 rc=0 time=7s peak=3144MB errors=0 sorry=0 +CongestionNativeNSig3 rc=0 time=7s peak=3144MB errors=0 sorry=0 +CongestionNativeNSig4 rc=0 time=7s peak=3155MB errors=0 sorry=0 +CongestionNativeNPt rc=0 time=23s peak=3294MB errors=0 sorry=0 +CongestionNativeNUnit rc=0 time=5s peak=2440MB errors=0 sorry=0 +CongestionNativeN rc=0 time=9s peak=2942MB errors=0 sorry=0 +JunkLawACeiling rc=0 time=6s peak=2858MB errors=0 sorry=0 +CongestionNativeZDefs rc=0 time=3s peak=1338MB errors=0 sorry=0 +CongestionNativeZSig0 rc=0 time=7s peak=3155MB errors=0 sorry=0 +CongestionNativeZSig1 rc=0 time=7s peak=3174MB errors=0 sorry=0 +CongestionNativeZSig2 rc=0 time=7s peak=3203MB errors=0 sorry=0 +CongestionNativeZSig3 rc=0 time=8s peak=3146MB errors=0 sorry=0 +CongestionNativeZSig4 rc=0 time=8s peak=3156MB errors=0 sorry=0 +CongestionNativeZPt rc=0 time=27s peak=3311MB errors=0 sorry=0 +CongestionNativeZUnit rc=0 time=6s peak=2429MB errors=0 sorry=0 +CongestionNativeZ rc=0 time=14s peak=2993MB errors=0 sorry=0 + +AXIOMS of the main theorems +'NumCertK.pow_lo' depends on axioms: [propext, Classical.choice, Quot.sound] +'NumCertK.pow_hi' depends on axioms: [propext, Classical.choice, Quot.sound] +'NumCertK.Fc_mono' depends on axioms: [propext, Classical.choice, Quot.sound] +'CongestionI3.cfB_neg' depends on axioms: [propext, Classical.choice, Quot.sound] +'CongestionI3.cfC88_neg' depends on axioms: [propext, Classical.choice, Quot.sound] +'CongestionI3.cfC_neg' depends on axioms: [propext, Classical.choice, Quot.sound] +'WholeFloorCover.cfW_neg' depends on axioms: [propext, Classical.choice, Quot.sound] +'CallerCost.reproduction' depends on axioms: [propext, Classical.choice, Quot.sound] +'CallerCost.S_caller' depends on axioms: [propext] +'CallerCost.S_7630_k17' depends on axioms: [propext, Quot.sound] +'CallerCost.D0_caller' depends on axioms: [propext, Classical.choice, Quot.sound] +'CallerCost.invoice_S' depends on axioms: [propext, Quot.sound] +'CallerCost.invoice_D0' depends on axioms: [propext, Classical.choice, Quot.sound] +'CallerCost.single_crossing' depends on axioms: [propext, Classical.choice, Quot.sound] +'CallerCost.cheaper_native_lowers_k' depends on axioms: [propext, Classical.choice, Quot.sound] +'CallerCost.crossing_value' depends on axioms: [propext, Classical.choice, Quot.sound] +'CallerCost.composition' depends on axioms: [propext, Classical.choice, Quot.sound] +'CallerCost.composition_helper' depends on axioms: [propext, Classical.choice, Quot.sound] +'CallerCost.naive_composition_false' depends on axioms: [propext, Classical.choice, Quot.sound] +'JointCeiling.invoice_F' depends on axioms: [propext, Classical.choice, Quot.sound] +'JointCeiling.natFloor_F' depends on axioms: [propext, Classical.choice, Quot.sound] +'JointCeiling.FB_eq' depends on axioms: [propext, Classical.choice, Quot.sound] +'JointCeiling.ceiling' depends on axioms: [propext, Classical.choice, Quot.sound] +'JointCeiling.ceiling4' depends on axioms: [propext, Classical.choice, Quot.sound] +'JointCeiling.ceiling3' depends on axioms: [propext, Classical.choice, Quot.sound] +'JointCeiling.rp_le_nat' depends on axioms: [propext, Classical.choice, Quot.sound] +'JointCeiling.rp_ge_nat' depends on axioms: [propext, Classical.choice, Quot.sound] +'JointCeiling.I22_F' depends on axioms: [propext, Classical.choice, Quot.sound] +'JointCeiling.split22_ceiling' depends on axioms: [propext, Classical.choice, Quot.sound] +'JointCeiling.ceiling_split22' depends on axioms: [propext, Classical.choice, Quot.sound] +'JointCeiling.callerG_F' depends on axioms: [propext, Classical.choice, Quot.sound] +'JointCeiling.callerG_S' depends on axioms: [propext, Classical.choice, Quot.sound] +'JointCeiling.callerG_eq_caller_F' depends on axioms: [propext, Classical.choice, Quot.sound] +'JointCeiling.split11_ceiling' depends on axioms: [propext, Classical.choice, Quot.sound] +'JointCeiling.ceiling_split11' depends on axioms: [propext, Classical.choice, Quot.sound] +'JointCeiling.I89_F' depends on axioms: [propext, Classical.choice, Quot.sound] +'JointCeiling.control_bracket' depends on axioms: [propext, Classical.choice, Quot.sound] +'WholeFloorCover.cover' depends on axioms: [propext, Classical.choice, Quot.sound] +'CongestionI3.forced_junk_ge' depends on axioms: [propext, Classical.choice, Quot.sound] +'CongestionI3.f1_floor' depends on axioms: [propext, Classical.choice, Quot.sound] +'CongestionI3.ceiling_A' depends on axioms: [propext, Classical.choice, Quot.sound] +'CongestionI3.chord_k' depends on axioms: [propext, Classical.choice, Quot.sound] +'CongestionI3.dprice_ge' depends on axioms: [propext, Classical.choice, Quot.sound] +'CongestionI3.nine_chord' depends on axioms: [propext, Classical.choice, Quot.sound] +'CongestionI3.own56_floor' depends on axioms: [propext, Classical.choice, Quot.sound] +'CongestionI3.ceiling_C' depends on axioms: [propext, Classical.choice, Quot.sound] +'TokenCancel.T1_hub_blind' depends on axioms: [propext, Quot.sound] +'TokenCancel.T1_two_runs' depends on axioms: [propext, Quot.sound] +'TokenCancel.T2_difference' depends on axioms: [propext, Quot.sound] +'TokenCancel.T2_corrected' depends on axioms: [propext, Quot.sound] +'TokenCancel.contacts_noscale' depends on axioms: [propext, Quot.sound] +'TokenCancel.T2_literal_false' depends on axioms: [propext, Classical.choice, Quot.sound] +'FrameSep.X_Y_never_share' depends on axioms: [propext, Quot.sound] +'FrameSep.reader_never_meets_Y_after' depends on axioms: [propext, Quot.sound] +'FrameSep.meet_before_read_possible' depends on axioms: [propext, Classical.choice, Quot.sound] +'FrameSep.Route.exit_owned' depends on axioms: [propext, Classical.choice, Quot.sound] +'FrameSep.owned_landing_then_ascent' depends on axioms: [propext, Classical.choice, Quot.sound] +'FrameSep.delivery_needs_ferry' depends on axioms: [propext, Classical.choice, Quot.sound] +'FrameSep.landing_ne_final' depends on axioms: [propext, Classical.choice, Quot.sound] +'JunkLB2.hsum_tele' depends on axioms: [propext, Classical.choice, Quot.sound] +'JunkLB2.kappa_le' depends on axioms: [propext, Classical.choice, Quot.sound] +'JunkLB2.g9_nonneg' depends on axioms: [propext, Classical.choice, Quot.sound] +'JunkLB2.T1_Y' depends on axioms: [propext, Classical.choice, Quot.sound] +'JunkLB2.l_nonneg' depends on axioms: [propext, Classical.choice, Quot.sound] +'JunkLB2.T1_Y_le' depends on axioms: [propext, Classical.choice, Quot.sound] +'JunkLB2.Net.T1_bound' depends on axioms: [propext, Classical.choice, Quot.sound] +'JunkLB2.slot_lemma' depends on axioms: [propext, Classical.choice, Quot.sound] +'JunkLB2.proj_exists' depends on axioms: [propext, Classical.choice, Quot.sound] +'JunkLB2.run_inv' depends on axioms: [propext, Classical.choice, Quot.sound] +'JunkLB2.strip_born' depends on axioms: [propext, Classical.choice, Quot.sound] +'JunkLB2.Net.movesOf_chain' depends on axioms: [propext, Classical.choice, Quot.sound] +'JunkLB2.Net.chain_hsum' depends on axioms: [propext, Classical.choice, Quot.sound] +'JunkLB2.Net.reg_le_V' depends on axioms: [propext, Classical.choice, Quot.sound] +'JunkLB2.Net.reg_le_Y' depends on axioms: [propext, Classical.choice, Quot.sound] +'JunkLB2.Net.T1_cost' depends on axioms: [propext, Classical.choice, Quot.sound] +'JunkLB2.Net.T1_full' depends on axioms: [propext, Classical.choice, Quot.sound] +'JunkLB2.compl_of_sup' depends on axioms: [propext, Classical.choice, Quot.sound] +'JunkLB2.T2_run' depends on axioms: [propext, Classical.choice, Quot.sound] +'JunkLB2.slot_lemma_T2' depends on axioms: [propext, Classical.choice, Quot.sound] +'JunkLB2.slot_lemma_run' depends on axioms: [propext, Classical.choice, Quot.sound] +'JunkLB2.T4_departer' depends on axioms: [propext, Classical.choice, Quot.sound] +'JunkLB2.T4_public' depends on axioms: [propext, Classical.choice, Quot.sound] +'JunkLB2.T4_stop_cost' depends on axioms: [propext, Classical.choice, Quot.sound] +'JunkLB2.T4_public_only_false' depends on axioms: [propext, Classical.choice, Quot.sound] +'RelaySandwich.restop_valid_iff' depends on axioms: [propext, Classical.choice, Quot.sound] +'RelaySandwich.route_collapse' depends on axioms: [propext, Classical.choice, Quot.sound] +'RelaySandwich.stopCost_fL' depends on axioms: [propext, Classical.choice, Quot.sound] +'RelaySandwich.stopCost_nine' depends on axioms: [propext, Classical.choice, Quot.sound] +'RelaySandwich.stopCost_k2' depends on axioms: [propext, Classical.choice, Quot.sound] +'RelaySandwich.stopCost_strictMono' depends on axioms: [propext, Classical.choice, Quot.sound] +'RankLaw.rank_law' depends on axioms: [propext, Classical.choice, Quot.sound] +'RankLaw.full_rank_iff_noloss' depends on axioms: [propext, Classical.choice, Quot.sound] +'RankLaw.vmixM_iff_span' depends on axioms: [propext, Classical.choice, Quot.sound] +'RankLaw.vmixM_fill' depends on axioms: [propext, Classical.choice, Quot.sound] +'RankLaw.vmix_ops' depends on axioms: [propext, Classical.choice, Quot.sound] +'RankLaw.vmixM_unique' depends on axioms: [propext, Classical.choice, Quot.sound] +'RankLaw.vmixM_indep' depends on axioms: [propext, Classical.choice, Quot.sound] +'RankLaw.copy_lossy_example' depends on axioms: [propext, Classical.choice, Quot.sound] +'RankLaw.add_inverse' depends on axioms: [propext, Classical.choice, Quot.sound] +'RankLaw.scale_inverse' depends on axioms: [propext, Classical.choice, Quot.sound] +'RankLaw.start_span' depends on axioms: [propext, Classical.choice, Quot.sound] +'SwapWord.absorb' depends on axioms: [propext, Classical.choice, Quot.sound] +'SwapWord.inject_two_col' depends on axioms: [propext, Classical.choice, Quot.sound] +'SwapWord.inject_col' depends on axioms: [propext, Classical.choice, Quot.sound] +'RankLawC.rank_law_proj' depends on axioms: [propext, Classical.choice, Quot.sound] +'RankLawC.rank_law_of_gen' depends on axioms: [propext, Classical.choice, Quot.sound] +'SwapNull.tail_run' depends on axioms: [propext, Classical.choice, Quot.sound] +'SwapNull.head_run' depends on axioms: [propext, Classical.choice, Quot.sound] +'SwapNull.gadget_legal' depends on axioms: [propext, Quot.sound] +'SwapNull.tail_iff' depends on axioms: [propext, Classical.choice, Quot.sound] +'SwapNull.tail_iff_span' depends on axioms: [propext, Classical.choice, Quot.sound] +'SwapNull.head_iff' depends on axioms: [propext, Classical.choice, Quot.sound] +'SwapNull.undo_one_iff' depends on axioms: [propext, Classical.choice, Quot.sound] +'SwapNull.delta_eq' depends on axioms: [propext, Classical.choice, Quot.sound] +'SwapNull.swap_null' depends on axioms: [propext, Classical.choice, Quot.sound] +'SwapNull.converse_witness' depends on axioms: [propext, Classical.choice, Quot.sound] +'SwapNull.tail_prefix_counterexample' depends on axioms: [propext, Classical.choice, Quot.sound] +'SwapNull.stays_multiset' depends on axioms: [propext, Classical.choice, Quot.sound] +'SwapNull.cost_stopCost' depends on axioms: [propext, Classical.choice, Quot.sound] +'FibreK.K_word' depends on axioms: [propext, Classical.choice, Quot.sound] +'FibreK.K_congr' depends on axioms: [propext, Classical.choice, Quot.sound] +'FibreK.K_invoice' depends on axioms: [propext, Classical.choice, Quot.sound] +'FibreK.kappa_depends_only' depends on axioms: [propext, Classical.choice, Quot.sound] +'FibreK.d0_native' depends on axioms: [propext, Classical.choice, Quot.sound] +'FibreK.tail_force' depends on axioms: [propext, Classical.choice, Quot.sound] +'FibreK.head_force' depends on axioms: [propext, Classical.choice, Quot.sound] +'FibreK.tail_pairs' depends on axioms: [propext, Classical.choice, Quot.sound] +'FibreK.head_pairs' depends on axioms: [propext, Classical.choice, Quot.sound] +'FibreK.tail_F_null' depends on axioms: [propext, Classical.choice, Quot.sound] +'FibreK.head_F_null' depends on axioms: [propext, Classical.choice, Quot.sound] +'FibreK.c3_not_undoable' depends on axioms: [propext, Classical.choice, Quot.sound] +'WordDuality.dual_run' depends on axioms: [propext, Quot.sound] +'WordDuality.Mrec_dual' depends on axioms: [propext, Classical.choice, Quot.sound] +'WordDuality.dualH_invoice' depends on axioms: [propext, Classical.choice, Quot.sound] +'WordDuality.word_invoice' depends on axioms: [propext, Classical.choice, Quot.sound] +'WordDuality.selfdual_boundary' depends on axioms: [propext, Quot.sound] +'WordDuality.nonhosted_block' depends on axioms: [propext, Classical.choice, Quot.sound] +'WordDuality.copy_not_add' depends on axioms: [propext, Classical.choice, Quot.sound] +'CongestionI3Dual.gs_subadd' depends on axioms: [propext, Classical.choice, Quot.sound] +'CongestionI3Dual.k0_eq_h9_swapN' depends on axioms: [propext, Classical.choice, Quot.sound] +'CongestionI3Dual.dualH_charge' depends on axioms: [propext, Classical.choice, Quot.sound] +'CongestionI3Dual.nonmixed_charge' depends on axioms: [propext, Classical.choice, Quot.sound] +'CongestionI3Dual.sum_c2_le' depends on axioms: [propext, Classical.choice, Quot.sound] +'CongestionI3Dual.sum_all_c2_le' depends on axioms: [propext, Classical.choice, Quot.sound] +'CongestionI3Dual.sig_of_ok' depends on axioms: [propext, Classical.choice, Quot.sound] +'CongestionNative.E_lower_cap_om' depends on axioms: [propext, Classical.choice, Quot.sound] +'CongestionNative.branchC_om' depends on axioms: [propext, Classical.choice, Quot.sound] +'CongestionNative.hcong_of_capclass' depends on axioms: [propext, Classical.choice, Quot.sound] +'CongestionNative.unit_mono' depends on axioms: [propext, Classical.choice, Quot.sound] +'CongestionNative.tab_piece' depends on axioms: [propext, Classical.choice, Quot.sound] +'CongestionNative.ceiling_native' depends on axioms: [propext, Classical.choice, Quot.sound] +'CongestionNative.unit_of_Fup' depends on axioms: [propext, Classical.choice, Quot.sound] +'CongestionNative.E_lower_cap_omN' depends on axioms: [propext, Classical.choice, Quot.sound] +'CongestionNative.tab_pieceJ' depends on axioms: [propext, Classical.choice, Quot.sound] +'CongestionNative.ceiling_native_J' depends on axioms: [propext, Classical.choice, Quot.sound] +'JunkLawA.maisBound' depends on axioms: [propext, Classical.choice, Quot.sound] +'JunkLawA.LawAModel.lawA' depends on axioms: [propext, Classical.choice, Quot.sound] +'JunkLawA.LawAModel.lawA_cs' depends on axioms: [propext, Classical.choice, Quot.sound] +'JunkLawA.LawAModel.lawA_lin' depends on axioms: [propext, Classical.choice, Quot.sound] +'JunkLawA.LawAModel.lawA_96' depends on axioms: [propext, Classical.choice, Quot.sound] +'JunkLawA.junkSet_card_ge_96' depends on axioms: [propext, Classical.choice, Quot.sound] +'JunkLawA.single_arrival_clique' depends on axioms: [propext, Classical.choice, Quot.sound] +'JunkLawA.single_arrival_junk' depends on axioms: [propext, Classical.choice, Quot.sound] +'CongestionNative.tab_pieceN' depends on axioms: [propext, Classical.choice, Quot.sound] +'CongestionNative.ceiling_native_N96' depends on axioms: [propext, Classical.choice, Quot.sound] +'CongestionNative.ceiling_noHJ' depends on axioms: [propext, Classical.choice, Quot.sound] +'CongestionNative.tab_pieceZ' depends on axioms: [propext, Classical.choice, Quot.sound] +'CongestionNative.ceiling_native_Z0' depends on axioms: [propext, Classical.choice, Quot.sound] + +AXIOM UNION over all logs + 155 [propext, Classical.choice, Quot.sound] + 12 [propext, Quot.sound] + 1 [propext] + +modules with rc=0: table_first.txt:1 table2.txt:64 +sorry / error mentions in logs: 0 diff --git a/research/p104-tiered-ceiling/LICENSE b/research/p104-tiered-ceiling/LICENSE new file mode 100644 index 0000000000..261eeb9e9f --- /dev/null +++ b/research/p104-tiered-ceiling/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/research/p104-tiered-ceiling/NATIVES.md b/research/p104-tiered-ceiling/NATIVES.md new file mode 100644 index 0000000000..dbb3e40f7d --- /dev/null +++ b/research/p104-tiered-ceiling/NATIVES.md @@ -0,0 +1,70 @@ +# NATIVES: which premises of the tiered ceilings each word meets, and the script that computed it + +Four word files were checked, each against every word-level premise of T1 (`ceiling_native_J`), T2a (`ceiling_noHJ`) and T2b (`ceiling_native_Z0`): + +| name | word | file | +|---|---|---| +| st1 | the word of #7641 | `st1.json.gz` | +| w7637 | the #7637 word | `w7637.json.gz` | +| x1t2a | the x1t2a word | `x1t2a.json.gz` | +| e1 | the #7660 word | `e1.json.gz` | + +All four share one owned layer (47 owned moves: 23 rises and 24 descents, mass 56 / 56) and one port set of 104 odd-weight vectors, so this is close to one data point, not four. A word that failed or could not be checked on any premise would be removed from the claims; none failed. **Lean treats every object in the three theorems as abstract and nothing in Lean ties a word to these hypotheses (in particular nothing ties the set `J` to a word).** The results below are exact computations by Python scripts (exact modular arithmetic over primes, exact integers, or outward-rounded 80-digit Decimal) run on the four word files, one core each. The scripts and word files are not part of this package. "Result" means the premise as computed, not a Lean fact. + +Script key (all re-run on all four words, outputs identical where stated): +- `aud.py WORD PRIME`: per-arrival content replay, run with p = 2^61 - 1 and p = 2^64 - 59 (both agree on all four words). +- `aud2.py WORD`: public register dimension sequences (hmono, hd9, hmix) and owned rise/descent split. +- `aud2a.py WORD`: structural audit, FIX-1 split (ks, mr), Cap class and slack grid. +- `aud2b.py WORD`, `hc12.py WORD`: arrival-form junk set `J^arr`, SP checks; `hc12.py` adds legal-path reachability for every junk cell. +- `aud2c.py WORD`: decoder-route endpoints and rank of route-end X-contents. +- `aud2d.py WORD`: the 48-cells law over all port-spanned subspaces of dimension <= 4 of F2^9. +- `hc6.py` (word list extended to the four words): ks, mr, hF, hst, hY, hmass, hmd, hmr on an s grid. +- `j13.py` (the four words): hF and hEex as exact identities of exponential polynomials, hst ingredients, Cap margin on s in [.9, 1 - tJ0]. +- `hc8.py WORD`, `hc11.py WORD`: route replay and forced-cell check. +- `hc9.py`, `jemit.py`, `emit.py`, `emit0.py`: certified bracket tables (word-independent). + +## Premise x word + +| premise (Lean name) | st1 | w7637 | x1t2a | e1 (#7660) | script | +|---|---|---|---|---|---| +| \|J^arr\| (for hJ : 4962 <= J.card) | 4962 | 4962 | 4962 | 4962 | `aud.py` (both primes), `aud2b.py`, `hc12.py` | +| per-row junk j_t; sum 1/(j_t+1) | [38, 48]; 2.1381 | same | same | same | `aud.py` | +| rank M | 11 | 11 | 11 | 11 | `aud.py` (15 distinct arrival vectors, rank 11) | +| D (arrival vectors, one per owned descending move; hD : D <= 56) | 24 | 24 | 24 | 24 | `aud.py`, `aud2a.py` (24 descents, 20 carry arrivals) | +| LawAModel hspan | holds | holds | holds | holds | `aud.py` (rows are combinations of the 15 arrival vectors by construction; rank equals rank M) | +| LawAModel hdiag (no zero diagonal) | 0 zero | 0 zero | 0 zero | 0 zero | `aud.py` | +| LawAModel hodd (odd off-diagonals vanish) | 0 odd | 0 odd | 0 odd | 0 odd | `aud.py` | +| LawAModel hpart (even partners <= 48) | 48 per row (4992) | 48 | 48 | 48 | `aud.py` | +| hmono | 0 violations | 0 | 0 | 0 | `aud2.py`, `aud2a.py` | +| hd9 | 0 violations | 0 | 0 | 0 | `aud2.py`, `aud2a.py` | +| hmix (<= 5) | 5 (tight) | 5 | 5 | 5 | `aud2.py`, `aud2a.py` | +| hk (every k in 1..9) | true | true | true | true | `hc6.py`, `aud2a.py` | +| hmass (56 <= ks.sum) | 102 | 102 | 102 | 102 | `hc6.py`, `aud2a.py` | +| hmd (8 <= len ks) | 37 | 37 | 37 | 37 | `hc6.py`, `aud2a.py` | +| hmr (8 <= mr) | 10 | 10 | 10 | 10 | `hc6.py`, `aud2a.py` | +| hY (104 <= st + len ks + mr) | st = 1266: 1313 | 1266: 1313 | st = 1265: 1312 | 1265: 1312 | `hc6.py`, `aud2a.py`, `j13.py` | +| hF (Finv s n <= ...) | exact identity, coefficient difference {} | {} | {} | {} | `j13.py` (and `hc6.py` on a grid: slack 0 up to 2e-12 float noise) | +| hEex (E := that exponential polynomial) | identity | identity | identity | identity | `j13.py` | +| hst | gaps >= 1, every main moves; grid slack >= 158 | >= 159 | >= 158 | >= 158 | `j13.py`, `hc6.py`; `aud2a.py` slack 0.0 at s = 1 only | +| Cap class (own cells, 48 N_f) | margin 19.349538 on s in [.9, 1 - tJ0] (`aud2a.py` grid: 19.356) | same | same | same | `j13.py`, `aud2a.py` | +| hcong / hdist support: every J^arr cell has a legal owned-descent-free path; no cell needs a cut | 0 cells without path | 0 | 0 | 0 | `hc12.py`; Cap margin as above | +| forced cells carry nonzero arrival coefficient | 2536 of 2536 | 2536 of 2536 | 2536 of 2536 | 2536 of 2536 | `hc11.py` | +| 48-cells law (max n*m over port-spanned subspaces) | 48 | 48 | 48 | 48 | `aud2d.py` (also `hc8.py`: native frames max 24) | +| 8 decoder routes, rank of route-end X-contents | 8 | 8 | 8 | 8 | `aud2c.py` | +| no public register enters any D_t; 0 SP violations; 0 even entries in Y_t | holds | holds | holds | holds | `aud2b.py`, `hc12.py` | + +Reading the table against the Lean statements: +- `hcong`, `hdist` are real-analytic statements about a given `J` and `distF`. The scripts compute the combinatorial and numerical ingredients (legal paths for every J^arr cell, the Cap margin on s in [.9, 1 - tJ0], which contains the T2 ranges s <= 1 - tN0 and s <= 1 - tZ0); the step from these computations to the Lean `hcong`/`hdist` for `J = J^arr` is the lane's paper argument and is not formalised. +- `hspMono`, `hcstMono` (monotonicity of spF, cst on [t0, 1/10]) are a paper theorem, not computed on a word and not formalised; they are word-independent. +- The bracket hypotheses (`hspTab`, `hcstTab`, `hspTabJ`, `hcstTabJ`, `hspTabN`, `hcstTabN`) are word-independent. `hc9.py` (C tables) and `jemit.py` (J tables) re-run with every inequality certified (outward-rounded Decimal, weights rounded down, constants rounded up). `emit.py` and `emit0.py` (N and Z tables) were re-run with their output redirected: the emitted rational tables are identical to `CongestionNativeNDefs.lean` and `CongestionNativeZDefs.lean`. The Lean hypotheses (`spFlo <= spF t`, `cst t <= cH`) remain hypotheses. +- Informational (`hc8.py`, not a Lean premise, identical on all four words): the route-end contents are not proportional to the cfg6 rows and the prefix property fails on 5 route events. Nothing in the three theorems uses them. +- The link from the Lean `n` and `caller 6 7` / 17 to each word's invoice is the pricing script's (`pricekit`), not Lean's. + +## What is not covered + +- Words with |J^arr| < 4962 are outside T1. They are covered by T2a/T2b only if they meet all the other hypotheses of that theorem (hmix <= 5, hmono, hd9, hk, hmass, hmd, hmr, hY, hF, hst, hEex, hcong, hdist, and for T2a the LawAModel premises, hD, hJdef). None of these has been checked on any such word. No such word is known. +- Words with D > 56: T2b only, with the same proviso. No such word was checked. +- Decoders with 9 or more rows: T1/T2 hard-code `corrC <= 8 * cH` and `capC >= unLo / 48`, which model 8 decoder rows and 48 partners per row. Such decoders are outside the model. +- That an owned mass above 56 never pays is a paper argument, absent from the Lean chain. +- The class-wide bound |J| >= 1936 for decoders that are not rank 8, C = 56 is a conjecture. +- Network decoders. diff --git a/research/p104-tiered-ceiling/PROVED.md b/research/p104-tiered-ceiling/PROVED.md new file mode 100644 index 0000000000..fe76262398 --- /dev/null +++ b/research/p104-tiered-ceiling/PROVED.md @@ -0,0 +1,250 @@ +# PROVED: statements of the main theorems, copied from the Lean sources + +Generated by a script that copies each statement (everything before `:=`) verbatim from `lean/Nov15/*.lean`. The Lean text is authoritative; every hypothesis in a statement is a hypothesis. All theorems below print axioms [propext, Classical.choice, Quot.sound] (CHECK.txt). Nothing here is a statement about a particular word: the objects `R, nR, dR, n, ks, mr, st, E, J, distF, spF, cstF, ...` are abstract, and Lean does not tie `J` to any word. + +## CongestionNativeJ.ceiling_native_J +```lean +theorem ceiling_native_J {ι : Type*} [DecidableEq ι] + (R : Finset ι) (nR : ι → ℕ) (dR : ι → ℕ → ℕ) + (hmono : ∀ r ∈ R, ∀ i < nR r, dR r i ≤ dR r (i + 1)) (hd9 : ∀ r ∈ R, dR r (nR r) ≤ 9) + (hmix : (R.filter fun r => Mixed dR nR r).card ≤ 5) + (n : Inv) (ks : List ℕ) (mr st : ℕ) (E : ℝ → ℝ) (J : Finset (ℕ × ℕ)) (distF : ℝ → ℕ × ℕ → ℝ) (spF cstF : ℝ → ℝ) + (hk : ∀ k ∈ ks, 1 ≤ k ∧ k ≤ 9) (hmass : 56 ≤ ks.sum) (hmd : 8 ≤ ks.length) (hmr : 8 ≤ mr) + (hF : ∀ s, 0 ≤ s → s ≤ 1 → Finv s n ≤ -400 * (8 : ℝ) ^ s - dprice ks s - mr - E s) + (hY : 104 ≤ st + (ks.length + mr)) + (hst : ∀ s, 0 ≤ s → s ≤ 1 → (2 - (2 : ℝ) ^ s) * st ≤ E s) + (hEex : ∀ s, 0 ≤ s → s ≤ 1 → ∑ r ∈ R, ex (gs s) (lev dR r) (nR r) ≤ E s) + (hcong : ∀ s, 9 / 10 ≤ s → s ≤ 1 - ((tJ0 : ℚ) : ℝ) → + ∑ p ∈ J, min (distF s p) (capC s) - corrC cstF s ≤ + ∑ r ∈ R, ∑ i ∈ range (nR r), c2 (gs s) (lev dR r i) (lev dR r (i + 1)) + Omega ks mr s) + (hdist : ∀ s, 9 / 10 ≤ s → s ≤ 1 - ((tJ0 : ℚ) : ℝ) → ∀ p ∈ J, spF (1 - s) ≤ distF s p) + (hJ : 4962 ≤ J.card) + (hspMono : MonotoneOn spF (Set.Icc ((tJ0 : ℚ) : ℝ) (1 / 10))) + (hcstMono : MonotoneOn cstF (Set.Icc ((tJ0 : ℚ) : ℝ) (1 / 10))) + (hspTab : ((spFloC0 : ℚ) : ℝ) ≤ spF ((tC0 : ℚ) : ℝ) ∧ ((spFloC1 : ℚ) : ℝ) ≤ spF ((tC1 : ℚ) : ℝ) ∧ + ((spFloC2 : ℚ) : ℝ) ≤ spF ((tC2 : ℚ) : ℝ) ∧ ((spFloC3 : ℚ) : ℝ) ≤ spF ((tC3 : ℚ) : ℝ)) + (hcstTab : cstF ((tC1 : ℚ) : ℝ) ≤ ((cHC0 : ℚ) : ℝ) ∧ cstF ((tC2 : ℚ) : ℝ) ≤ ((cHC1 : ℚ) : ℝ) ∧ + cstF ((tC3 : ℚ) : ℝ) ≤ ((cHC2 : ℚ) : ℝ) ∧ cstF (1 / 10) ≤ ((cHC3 : ℚ) : ℝ)) + (hspTabJ : ((spFloJ0 : ℚ) : ℝ) ≤ spF ((tJ0 : ℚ) : ℝ) ∧ ((spFloJ1 : ℚ) : ℝ) ≤ spF ((tJ1 : ℚ) : ℝ) ∧ + ((spFloJ2 : ℚ) : ℝ) ≤ spF ((tJ2 : ℚ) : ℝ)) + (hcstTabJ : cstF ((tJ1 : ℚ) : ℝ) ≤ ((cHJ0 : ℚ) : ℝ) ∧ cstF ((tJ2 : ℚ) : ℝ) ≤ ((cHJ1 : ℚ) : ℝ) ∧ + cstF ((tC0 : ℚ) : ℝ) ≤ ((cHJ2 : ℚ) : ℝ)) : + ∀ t : ℝ, ((tJ0 : ℚ) : ℝ) ≤ t → t ≤ 1 → Finv (1 - t) (invoice (caller 6 7) n 17) < 0 +``` + +## JunkLawACeiling.ceiling_noHJ +```lean +theorem ceiling_noHJ {ι : Type*} [DecidableEq ι] {K : Type*} [Field K] {D : ℕ} + (m : JunkLawA.LawAModel K 104 D) (hD : D ≤ 56) + (R : Finset ι) (nR : ι → ℕ) (dR : ι → ℕ → ℕ) + (hmono : ∀ r ∈ R, ∀ i < nR r, dR r i ≤ dR r (i + 1)) (hd9 : ∀ r ∈ R, dR r (nR r) ≤ 9) + (hmix : (R.filter fun r => Mixed dR nR r).card ≤ 5) + (n : Inv) (ks : List ℕ) (mr st : ℕ) (E : ℝ → ℝ) (J : Finset (ℕ × ℕ)) (distF : ℝ → ℕ × ℕ → ℝ) (spF cstF : ℝ → ℝ) + (hk : ∀ k ∈ ks, 1 ≤ k ∧ k ≤ 9) (hmass : 56 ≤ ks.sum) (hmd : 8 ≤ ks.length) (hmr : 8 ≤ mr) + (hF : ∀ s, 0 ≤ s → s ≤ 1 → Finv s n ≤ -400 * (8 : ℝ) ^ s - dprice ks s - mr - E s) + (hY : 104 ≤ st + (ks.length + mr)) + (hst : ∀ s, 0 ≤ s → s ≤ 1 → (2 - (2 : ℝ) ^ s) * st ≤ E s) + (hEex : ∀ s, 0 ≤ s → s ≤ 1 → ∑ r ∈ R, ex (gs s) (lev dR r) (nR r) ≤ E s) + (hcong : ∀ s, 9 / 10 ≤ s → s ≤ 1 - ((tN0 : ℚ) : ℝ) → + ∑ p ∈ J, min (distF s p) (capC s) - corrC cstF s ≤ + ∑ r ∈ R, ∑ i ∈ range (nR r), c2 (gs s) (lev dR r i) (lev dR r (i + 1)) + Omega ks mr s) + (hdist : ∀ s, 9 / 10 ≤ s → s ≤ 1 - ((tN0 : ℚ) : ℝ) → ∀ p ∈ J, spF (1 - s) ≤ distF s p) + (hJdef : J = JunkLawA.junkSet m.M) + (hspMono : MonotoneOn spF (Set.Icc ((tN0 : ℚ) : ℝ) (1 / 10))) + (hcstMono : MonotoneOn cstF (Set.Icc ((tN0 : ℚ) : ℝ) (1 / 10))) + (hspTabN : ((spFloN0 : ℚ) : ℝ) ≤ spF ((tN0 : ℚ) : ℝ) ∧ ((spFloN1 : ℚ) : ℝ) ≤ spF ((tN1 : ℚ) : ℝ) ∧ + ((spFloN2 : ℚ) : ℝ) ≤ spF ((tN2 : ℚ) : ℝ) ∧ ((spFloN3 : ℚ) : ℝ) ≤ spF ((tN3 : ℚ) : ℝ) ∧ + ((spFloN4 : ℚ) : ℝ) ≤ spF ((tN4 : ℚ) : ℝ)) + (hcstTabN : cstF ((tN1 : ℚ) : ℝ) ≤ ((cHN0 : ℚ) : ℝ) ∧ cstF ((tN2 : ℚ) : ℝ) ≤ ((cHN1 : ℚ) : ℝ) ∧ + cstF ((tN3 : ℚ) : ℝ) ≤ ((cHN2 : ℚ) : ℝ) ∧ cstF ((tN4 : ℚ) : ℝ) ≤ ((cHN3 : ℚ) : ℝ) ∧ + cstF ((tN5 : ℚ) : ℝ) ≤ ((cHN4 : ℚ) : ℝ)) : + ∀ t : ℝ, ((tN0 : ℚ) : ℝ) ≤ t → t ≤ 1 → Finv (1 - t) (invoice (caller 6 7) n 17) < 0 +``` + +## CongestionNativeZ.ceiling_native_Z0 +```lean +theorem ceiling_native_Z0 {ι : Type*} [DecidableEq ι] + (R : Finset ι) (nR : ι → ℕ) (dR : ι → ℕ → ℕ) + (hmono : ∀ r ∈ R, ∀ i < nR r, dR r i ≤ dR r (i + 1)) (hd9 : ∀ r ∈ R, dR r (nR r) ≤ 9) + (hmix : (R.filter fun r => Mixed dR nR r).card ≤ 5) + (n : Inv) (ks : List ℕ) (mr st : ℕ) (E : ℝ → ℝ) (J : Finset (ℕ × ℕ)) (distF : ℝ → ℕ × ℕ → ℝ) (spF cstF : ℝ → ℝ) + (hk : ∀ k ∈ ks, 1 ≤ k ∧ k ≤ 9) (hmass : 56 ≤ ks.sum) (hmd : 8 ≤ ks.length) (hmr : 8 ≤ mr) + (hF : ∀ s, 0 ≤ s → s ≤ 1 → Finv s n ≤ -400 * (8 : ℝ) ^ s - dprice ks s - mr - E s) + (hY : 104 ≤ st + (ks.length + mr)) + (hst : ∀ s, 0 ≤ s → s ≤ 1 → (2 - (2 : ℝ) ^ s) * st ≤ E s) + (hEex : ∀ s, 0 ≤ s → s ≤ 1 → ∑ r ∈ R, ex (gs s) (lev dR r) (nR r) ≤ E s) + (hcong : ∀ s, 9 / 10 ≤ s → s ≤ 1 - ((tZ0 : ℚ) : ℝ) → + ∑ p ∈ J, min (distF s p) (capC s) - corrC cstF s ≤ + ∑ r ∈ R, ∑ i ∈ range (nR r), c2 (gs s) (lev dR r i) (lev dR r (i + 1)) + Omega ks mr s) + (hdist : ∀ s, 9 / 10 ≤ s → s ≤ 1 - ((tZ0 : ℚ) : ℝ) → ∀ p ∈ J, spF (1 - s) ≤ distF s p) + (hspMono : MonotoneOn spF (Set.Icc ((tZ0 : ℚ) : ℝ) (1 / 10))) + (hcstMono : MonotoneOn cstF (Set.Icc ((tZ0 : ℚ) : ℝ) (1 / 10))) + (hspTabN : ((spFloZ0 : ℚ) : ℝ) ≤ spF ((tZ0 : ℚ) : ℝ) ∧ ((spFloZ1 : ℚ) : ℝ) ≤ spF ((tZ1 : ℚ) : ℝ) ∧ + ((spFloZ2 : ℚ) : ℝ) ≤ spF ((tZ2 : ℚ) : ℝ) ∧ ((spFloZ3 : ℚ) : ℝ) ≤ spF ((tZ3 : ℚ) : ℝ) ∧ + ((spFloZ4 : ℚ) : ℝ) ≤ spF ((tZ4 : ℚ) : ℝ)) + (hcstTabN : cstF ((tZ1 : ℚ) : ℝ) ≤ ((cHZ0 : ℚ) : ℝ) ∧ cstF ((tZ2 : ℚ) : ℝ) ≤ ((cHZ1 : ℚ) : ℝ) ∧ + cstF ((tZ3 : ℚ) : ℝ) ≤ ((cHZ2 : ℚ) : ℝ) ∧ cstF ((tZ4 : ℚ) : ℝ) ≤ ((cHZ3 : ℚ) : ℝ) ∧ + cstF ((tZ5 : ℚ) : ℝ) ≤ ((cHZ4 : ℚ) : ℝ)) : + ∀ t : ℝ, ((tZ0 : ℚ) : ℝ) ≤ t → t ≤ 1 → Finv (1 - t) (invoice (caller 6 7) n 17) < 0 +``` + +## JunkLawA.LawAModel (structure; its fields are the premises hspan, hdiag, hodd, hpart) +```lean +structure LawAModel (K : Type*) [Field K] (P D : ℕ) where + M : Matrix (Fin P) (Fin P) K + arr : Fin D → (Fin P → K) + /-- every row `v_t` is a combination of arrivals: one arrival vector per owned descending move -/ + hspan : ∀ t, M t ∈ Submodule.span K (Set.range arr) + /-- Y_t odd spec: the diagonal coefficient `c_t ≠ 0` -/ + hdiag : ∀ t, M t t ≠ 0 + /-- `Ev t s`: `s` is an even partner of `t` -/ + Ev : Fin P → Fin P → Prop + /-- odd off-diagonals vanish -/ + hodd : ∀ t s, s ≠ t → M t s ≠ 0 → Ev t s + /-- 48 even partners -/ + hpart : ∀ t, (univ.filter fun s => s ≠ t ∧ Ev t s).card ≤ 48 +``` + +## JunkLawA.lawA_96 +```lean +-- section variables in scope: {K : Type*} [Field K] {D : ℕ} (P is fixed to 104 in the statement) +theorem lawA_96 (m : LawAModel K 104 D) (hD : D ≤ 56) : 96 ≤ m.J +``` + +## JunkLawA.junkSet_card_ge_96 +```lean +-- section variables in scope: {K : Type*} [Field K] +theorem junkSet_card_ge_96 {D : ℕ} (m : LawAModel K 104 D) (hD : D ≤ 56) : 96 ≤ (junkSet m.M).card +``` + +## JunkLawA.maisBound +```lean +-- section variables in scope: {P : ℕ} {K : Type*} [Field K] +theorem maisBound (M : Matrix (Fin P) (Fin P) K) (hdiag : ∀ t, M t t ≠ 0) : + ∑ t, (1 : ℝ) / (jc M t + 1) ≤ M.rank +``` + +## Appendix: definitions and values (copied from the Lean sources) + +Breakpoints and bracket rationals (`CongestionNativeJDefs.lean`, `CongestionNativeNDefs.lean`, `CongestionNativeZDefs.lean`, `CongestionNativeTab.lean`, `CongestionI3DualConst.lean`), all `def … : ℚ` in `namespace CongestionNative` (`tC*` in `CongestionI3Dual`). The t0 of the three theorems are `tJ0` (T1), `tN0` (T2a), `tZ0` (T2b). + +### T1 breakpoints, cst brackets and spF lower bounds (`CongestionNativeJDefs.lean`) +```lean +def tJ0 : ℚ := 118103 / 10 ^ 7 +def tJ1 : ℚ := 118123 / 10 ^ 7 +def tJ2 : ℚ := 120123 / 10 ^ 7 +def cHJ0 : ℚ := 291901 / 10 ^ 7 +def cHJ1 : ℚ := 296781 / 10 ^ 7 +def cHJ2 : ℚ := 336819 / 10 ^ 7 +def spFloJ0 : ℚ := 113518785551 / 20000000000000 +def spFloJ1 : ℚ := 17740285593 / 3125000000000 +def spFloJ2 : ℚ := 577208719357 / 100000000000000 +``` + +### T2a breakpoints and brackets (`CongestionNativeNDefs.lean`) +```lean +def tN0 : ℚ := 151027 / 10 ^ 7 +def tN1 : ℚ := 151077 / 10 ^ 7 +def tN2 : ℚ := 153077 / 10 ^ 7 +def tN3 : ℚ := 253077 / 10 ^ 7 +def tN4 : ℚ := 7 / 100 +def tN5 : ℚ := 1 / 10 +def cHN0 : ℚ := 23253 / 625000 +def spFloN0 : ℚ := 723917880571 / 100000000000000 +def cHN1 : ℚ := 188447 / 5000000 +def spFloN1 : ℚ := 362077327347 / 50000000000000 +def cHN2 : ℚ := 77077 / 1250000 +def spFloN2 : ℚ := 45851503937 / 6250000000000 +def cHN3 : ℚ := 1628077 / 10000000 +def spFloN3 : ℚ := 1203242422603 / 100000000000000 +def cHN4 : ℚ := 2255027 / 10000000 +def spFloN4 : ℚ := 3212352863571 / 100000000000000 +``` + +### T2b breakpoints and brackets (`CongestionNativeZDefs.lean`) +```lean +def tZ0 : ℚ := 151869 / 10 ^ 7 +def tZ1 : ℚ := 151889 / 10 ^ 7 +def tZ2 : ℚ := 152889 / 10 ^ 7 +def tZ3 : ℚ := 202889 / 10 ^ 7 +def tZ4 : ℚ := 7 / 100 +def tZ5 : ℚ := 1 / 10 +def cHZ0 : ℚ := 74803 / 2000000 +def spFloZ0 : ℚ := 363952451801 / 50000000000000 +def cHZ1 : ℚ := 188219 / 5000000 +def spFloZ1 : ℚ := 727999600691 / 100000000000000 +def cHZ2 : ℚ := 496937 / 10000000 +def spFloZ2 : ℚ := 366367033967 / 50000000000000 +def cHZ3 : ℚ := 1628077 / 10000000 +def spFloZ3 : ℚ := 968491930913 / 100000000000000 +def cHZ4 : ℚ := 2255027 / 10000000 +def spFloZ4 : ℚ := 3212352863571 / 100000000000000 +``` + +### C-class breakpoints (`CongestionI3DualConst.lean`) +```lean +def tC0 : ℚ := 136564 / 10 ^ 7 +def tC1 : ℚ := 136584 / 10 ^ 7 +def tC2 : ℚ := 137584 / 10 ^ 7 +def tC3 : ℚ := 237584 / 10 ^ 7 +``` + +### C-class brackets (T1 `hspTab`, `hcstTab`) (`CongestionNativeTab.lean`) +```lean +def spFloC0 : ℚ := 131069767447 / 20000000000000 +def spFloC1 : ℚ := 655443767027 / 100000000000000 +def spFloC2 : ℚ := 26407594739 / 4000000000000 +def spFloC3 : ℚ := 141372084217 / 12500000000000 +def cHC0 : ℚ := 84217 / 2500000 +def cHC1 : ℚ := 339299 / 10 ^ 7 +def cHC2 : ℚ := 579807 / 10 ^ 7 +def cHC3 : ℚ := 2255027 / 10 ^ 7 +``` + +### Invoice, caller and Finv +Namespaces: `CallerCost` (`Hist`, `Inv`, `scale`, `invoice`, `armT`, `armP`, `callerT`, `callerP`, `caller`), `JointCeiling` (`Fh`, `Finv`). + +```lean +abbrev Hist := List (ℕ × ℕ) +structure Inv where + T : Hist + P : Hist +def scale (L : ℕ) (l : Hist) : Hist := l.map fun p => (p.1, L * p.2) +def invoice (c n : Inv) (L : ℕ) : Inv := ⟨c.T ++ scale L n.T, c.P ++ scale L n.P⟩ +def armT (n c : ℕ) : Hist := (List.range n).map fun i => (8 * i + 9, c) +def armP (m c : ℕ) : Hist := (List.range m).map fun i => (8 * i + 16, c) +def callerT (a b : ℕ) : Hist := armT (a + 2) 208 ++ armT (b + 2) 208 ++ [(8 * (a + b + 4) + 1, 208)] +def callerP (a b : ℕ) : Hist := + armP a 208 ++ armP b 208 ++ [(8, 384), (1, 384), (8, 16 * (a + b + 4)), (9, 32)] +def caller (a b : ℕ) : Inv := ⟨callerT a b, callerP a b⟩ +noncomputable def Fh (s : ℝ) (l : Hist) : ℝ := (l.map fun p => (p.2 : ℝ) * (p.1 : ℝ) ^ s).sum +noncomputable def Finv (s : ℝ) (i : Inv) : ℝ := Fh s i.T - Fh s i.P +``` + +### Owned-surplus and cap definitions (`CongestionNative.lean`), price and register definitions +```lean +noncomputable def Omega (ks : List ℕ) (mr : ℕ) (s : ℝ) : ℝ := dprice ks s + mr - (6 * (9 : ℝ) ^ s + 10) +noncomputable def capC (s : ℝ) : ℝ := ((9 : ℝ) ^ s - (8 : ℝ) ^ s) / 48 +noncomputable def corrC (cstF : ℝ → ℝ) (s : ℝ) : ℝ := 8 * cstF (1 - s) +noncomputable def dprice (ks : List ℕ) (s : ℝ) : ℝ := (ks.map fun k : ℕ => ((k : ℕ) : ℝ) ^ s).sum +def h9 (g : ℝ → ℝ) (a b : ℝ) : ℝ := g (b - a) + g (9 - b) - g (9 - a) +def k0 (g : ℝ → ℝ) (a b : ℝ) : ℝ := g (b - a) + g a - g b +def c2 (g : ℝ → ℝ) (a b : ℝ) : ℝ := min (h9 g a b) (k0 g a b) +noncomputable def gs (s : ℝ) (x : ℝ) : ℝ := if 0 < x then x ^ s else 0 +def gsum (g : ℝ → ℝ) (d : ℕ → ℝ) (n : ℕ) : ℝ := ∑ i ∈ range n, g (d (i + 1) - d i) +def ex (g : ℝ → ℝ) (d : ℕ → ℝ) (n : ℕ) : ℝ := gsum g d n - g (d n - d 0) +def Mixed (d : ι → ℕ → ℕ) (n : ι → ℕ) (r : ι) : Prop := 1 ≤ d r 0 ∧ d r (n r) ≤ 8 +def lev (d : ι → ℕ → ℕ) (r : ι) : ℕ → ℝ := fun i => (d r i : ℝ) +``` + +### Junk sets (`JunkLawA.lean`) +```lean +noncomputable def outN (M : Matrix (Fin P) (Fin P) K) (t : Fin P) : Finset (Fin P) := + univ.filter fun s => s ≠ t ∧ M t s ≠ 0 +noncomputable def jc (M : Matrix (Fin P) (Fin P) K) (t : Fin P) : ℕ := (outN M t).card +-- inside namespace LawAModel, with {D : ℕ} (m : LawAModel K P D): +noncomputable def j (t : Fin P) : ℕ := jc m.M t +noncomputable def J : ℕ := ∑ t, m.j t +noncomputable def junkSet (M : Matrix (Fin P) (Fin P) K) : Finset (ℕ × ℕ) := + (univ.filter fun p : Fin P × Fin P => p.1 ≠ p.2 ∧ M p.1 p.2 ≠ 0).image fun p => ((p.1 : ℕ), (p.2 : ℕ)) +``` diff --git a/research/p104-tiered-ceiling/PR_BODY.md b/research/p104-tiered-ceiling/PR_BODY.md new file mode 100644 index 0000000000..2fe0d3f51c --- /dev/null +++ b/research/p104-tiered-ceiling/PR_BODY.md @@ -0,0 +1,24 @@ +P104: tiered ceilings for words meeting the native-class hypotheses (incl. the frontier words), Lean only + +Lean-only package, builds on #7656 and #7659 (their modules are included unchanged; new modules: the T1 pieces `CongestionNativeJ*`, `JunkLawA`, `JunkLawACeiling`, the N96 and Z0 pieces `CongestionNativeN*`, `CongestionNativeZ*`). No κ claim and no word claim in Lean. + +**Results.** Each theorem proves `Finv (1 − t) (invoice (caller 6 7) n 17) < 0`, the F-form of the 17-call invoice of the #7113 caller C(8|9), for every t with t0 ≤ t ≤ 1, under its full hypothesis list in `PROVED.md` (copied from the Lean text; the same hypotheses are also listed by script in `README.md`). +- **T1**, `ceiling_native_J`: t0 = .0118103 (`tJ0`). Hypotheses include the junk count `hJ : 4962 ≤ J.card`. +- **T2a**, `ceiling_noHJ`: t0 = .0151027 (`tN0`). No junk-count hypothesis (`96 ≤ |J|` is derived in Lean from Law A, `JunkLawA.lean`), but it needs `m : LawAModel K 104 D` (`hspan`, `hdiag`, `hodd`, `hpart ≤ 48`), `hD : D ≤ 56` and `hJdef : J = junkSet m.M`. +- **T2b**, `ceiling_native_Z0`: t0 = .0151869 (`tZ0`). No junk-count hypothesis and no upper bound on owned mass (none of T1, T2a, T2b bounds `ks.sum` from above; all keep `hmass : 56 ≤ ks.sum`). + +"For the frontier words" means: the frontier words satisfy all the hypotheses of these theorems (computed, `NATIVES.md`, a table of premise × word → result and script). Checked on all four of `st1` (#7641), the #7637 word, `x1t2a` and the #7660 word: |J^arr| = 4962, rank M = 11, D = 24, the LawAModel premises, hmono, hd9, hmix = 5 (tight), hk, hmass, hmd, hmr, hY, hF, hEex, hst, the Cap class, and the legal-path and Cap-margin ingredients of hcong / hdist. They share one owned layer and one port set, so this is close to a single data point. The link from the Lean invoice to each word's pricing is the pricing script's. Nothing in Lean ties a word to the hypotheses. + +Law A as proved in Lean is `lawA_96`: for `m : LawAModel K 104 D` with `D ≤ 56` (premises `hspan`, `hdiag`, `hodd`, `hpart ≤ 48`, P = 104), `96 ≤ m.J`. Behind it, `maisBound` (Caro-Wei, needs `hdiag`) gives Σ_t 1/(j_t+1) ≤ rank M, and rank M ≤ D by `hspan`. The general inequality J ≥ 2(P − D) is not stated in Lean. All theorems print only propext, Classical.choice, Quot.sound; no `sorry`, no `native_decide` (`CHECK.txt`). + +**Caveats, stated plainly.** +- T1 covers only words with |J^arr| ≥ 4962. A word with less arrival junk (rank 9, 10, 11 decoder matrices with J = 4336, 3728, 3168 exist; whether any is realisable as a word is open) is covered by T2a or T2b only if it meets all their other hypotheses (hmix ≤ 5, hmono, hd9, hk, hmass, hmd, hmr, hY, hF, hst, hEex, hcong, hdist, and for T2a the LawAModel premises, `hD`, `hJdef`). Those are not checked for any such word, and hmix = 5 is tight on the known words. The same holds for a word with D > 56 and T2b. +- T1 and T2 hard-code the 8-row decoder constants (`corrC ≤ 8 · cH`, `capC ≥ unLo / 48`). Decoders with 9 or more rows are outside the model; rank 9, 10, 11 matrices that need that many rows are not covered. +- `hJdef : J = junkSet m.M` is not a naming link only: it forces `hcong` and `hdist` (real-valued statements) to hold on exactly the off-diagonal support of `m.M`. In T1, `J` is any finset with `hJ`; in T2b, `J` and `distF` are still quantified and `hcong`, `hdist` are assumed (even for `J = ∅`). Lean does not tie `J` to `J^arr` of a word. +- `hcong`, `hdist`, the spF / cst brackets and the monotonicity `hspMono`, `hcstMono` (a paper theorem) are hypotheses in Lean, as are the Law A premises. `NATIVES.md` computes their ingredients on the four words; the step from the computations to the Lean statements is not formalised. +- "Owned mass > 56 never pays" is a paper argument and not in Lean. `hD` in T2a is the size of any spanning set of arrival vectors, so in effect rank M ≤ 56 (the words have rank 11, D = 24). Intermediate ceilings for 56 < D < 104 were not built. +- `CHECK.txt`: 65 of the 66 modules were compiled fresh. `CongestionI3Cfg` (unchanged from #7656, where it built fresh) was stopped by the 3.5 GB memory guard at about 3.44 GB, twice, so its prebuilt olean from the earlier build was used for the modules that import it. + +Premises under study are SYLforge's (#7616, #7620); the caller is rohanarun's (#7113). DreamingOfClouds with Claude Opus 5.5 (Anthropic), via Claude Code. + +🤖 Generated with [Claude Code](https://claude.com/claude-code) diff --git a/research/p104-tiered-ceiling/README.md b/research/p104-tiered-ceiling/README.md new file mode 100644 index 0000000000..03a9c50cfa --- /dev/null +++ b/research/p104-tiered-ceiling/README.md @@ -0,0 +1,96 @@ +# P104: tiered ceilings for words meeting the native-class hypotheses (incl. the frontier words): t0 = .0118103 at the junk count, t0 = .0151027 / .0151869 with no junk assumption (Lean, no kappa) + +Authors: DreamingOfClouds with Claude Opus 5.5 (Anthropic), via Claude Code. **No kappa claim.** Everything here is a Lean statement with named hypotheses. Lean proves nothing about the extracted data's fidelity, the word files, or the checker scripts; those premises are listed in `NATIVES.md`. + +## The three theorems +All three conclude `F(1 - t, invoice (caller 6 7) n 17) < 0` for `t` in `[t0, 1]`, i.e. kappa <= `t0` for any word meeting the hypotheses, on the 17-call invoice of the #7113 caller C(8|9). + +| tag | theorem (module) | `t0` | junk assumption | extra | +|---|---|---|---|---| +| T1 | `CongestionNative.ceiling_native_J` (`CongestionNativeJ`) | .0118103 | `hJ : 4962 <= J.card` | covers only words with at least 4962 junk cells | +| T2a | `CongestionNative.ceiling_noHJ` (`JunkLawACeiling`) | .0151027 | none: `hJ` is derived from Law A | `hD : D <= 56`, which in Lean means rank M <= 56 (any spanning set of D arrival vectors) | +| T2b | `CongestionNative.ceiling_native_Z0` (`CongestionNativeZ`) | .0151869 | none | no junk count and no upper bound on owned mass; it still assumes `hmass : 56 <= ks.sum`, `hk`, `hmd`, `hmr`, `hY` and the rest of class K | + +`JunkLawA` proves Law A in Lean (`maisBound`: sum over t of 1/(j_t+1) <= rank M, by Caro-Wei over all rankings, needs `hdiag`; with rank M <= D from `hspan`, the Lean theorem `lawA_96` states 96 <= J for `m : LawAModel K 104 D`, D <= 56, under all LawAModel premises incl. `hpart <= 48`; the general inequality J >= 2(P - D) is not stated in Lean). Its premises are the named fields of the structure `LawAModel` (`hspan`, `hdiag`, `hodd`, `hpart`); the register-machine facts behind `hspan` are not formalised. + +## Hypotheses (generated from the Lean statements) +The lists below were extracted by script from the binders of the three theorems; the full text of every binder is in `PROVED.md`. All of them are hypotheses of the Lean statements. `hcong`, `hdist` and `J` in particular: `J` is an arbitrary finite set of cells, and Lean does not tie it to any word. In T2a, `hJdef : J = junkSet m.M` is not a naming link only: it forces `hcong` and `hdist` to hold on exactly the off-diagonal support of `m.M`. T1 and T2 hard-code 8-row decoder constants (`corrC <= 8 * cH`, `capC >= unLo / 48`), so decoders with 9 or more rows are outside the model. + +Hypotheses (binders) of each theorem, extracted by script from the Lean statements. Names shared by all three are listed once. + +- `ceiling_native_J` [T1]: `R`, `nR`, `dR`, `hmono`, `hd9`, `hmix`, `n`, `ks`, `mr st`, `E`, `J`, `distF`, `spF cstF`, `hk`, `hmass`, `hmd`, `hmr`, `hF`, `hY`, `hst`, `hEex`, `hcong`, `hdist`, `hJ`, `hspMono`, `hcstMono`, `hspTab`, `hcstTab`, `hspTabJ`, `hcstTabJ` +- `ceiling_noHJ` [T2 (needs hD, rank M <= 56)]: `m`, `hD`, `R`, `nR`, `dR`, `hmono`, `hd9`, `hmix`, `n`, `ks`, `mr st`, `E`, `J`, `distF`, `spF cstF`, `hk`, `hmass`, `hmd`, `hmr`, `hF`, `hY`, `hst`, `hEex`, `hcong`, `hdist`, `hJdef`, `hspMono`, `hcstMono`, `hspTabN`, `hcstTabN` +- `ceiling_native_Z0` [T2 (no junk count, no mass upper bound)]: `R`, `nR`, `dR`, `hmono`, `hd9`, `hmix`, `n`, `ks`, `mr st`, `E`, `J`, `distF`, `spF cstF`, `hk`, `hmass`, `hmd`, `hmr`, `hF`, `hY`, `hst`, `hEex`, `hcong`, `hdist`, `hspMono`, `hcstMono`, `hspTabN`, `hcstTabN` + +- `ceiling_noHJ` relative to `ceiling_native_J`: removes `hJ`, `hspTab`, `hcstTab`, `hspTabJ`, `hcstTabJ`; adds `m`, `hD`, `hJdef`, `hspTabN`, `hcstTabN` +- `ceiling_native_Z0` relative to `ceiling_native_J`: removes `hJ`, `hspTab`, `hcstTab`, `hspTabJ`, `hcstTabJ`; adds `hspTabN`, `hcstTabN` + +Every binder with its Lean type (T1 = `ceiling_native_J`, T2a = `ceiling_noHJ`, T2b = `ceiling_native_Z0`): + +Hypotheses (binders) of each theorem, extracted by script from the Lean statements. Names shared by all three are listed once. + +- `ceiling_native_J` [T1]: `R`, `nR`, `dR`, `hmono`, `hd9`, `hmix`, `n`, `ks`, `mr st`, `E`, `J`, `distF`, `spF cstF`, `hk`, `hmass`, `hmd`, `hmr`, `hF`, `hY`, `hst`, `hEex`, `hcong`, `hdist`, `hJ`, `hspMono`, `hcstMono`, `hspTab`, `hcstTab`, `hspTabJ`, `hcstTabJ` +- `ceiling_noHJ` [T2 (needs hD, rank M <= 56)]: `m`, `hD`, `R`, `nR`, `dR`, `hmono`, `hd9`, `hmix`, `n`, `ks`, `mr st`, `E`, `J`, `distF`, `spF cstF`, `hk`, `hmass`, `hmd`, `hmr`, `hF`, `hY`, `hst`, `hEex`, `hcong`, `hdist`, `hJdef`, `hspMono`, `hcstMono`, `hspTabN`, `hcstTabN` +- `ceiling_native_Z0` [T2 (no junk count, no mass upper bound)]: `R`, `nR`, `dR`, `hmono`, `hd9`, `hmix`, `n`, `ks`, `mr st`, `E`, `J`, `distF`, `spF cstF`, `hk`, `hmass`, `hmd`, `hmr`, `hF`, `hY`, `hst`, `hEex`, `hcong`, `hdist`, `hspMono`, `hcstMono`, `hspTabN`, `hcstTabN` + +- `ceiling_noHJ` relative to `ceiling_native_J`: removes `hJ`, `hspTab`, `hcstTab`, `hspTabJ`, `hcstTabJ`; adds `m`, `hD`, `hJdef`, `hspTabN`, `hcstTabN` +- `ceiling_native_Z0` relative to `ceiling_native_J`: removes `hJ`, `hspTab`, `hcstTab`, `hspTabJ`, `hcstTabJ`; adds `hspTabN`, `hcstTabN` +| hypothesis | in | Lean type | +|---|---|---| +| `R` | T1, T2a, T2b | `Finset ι` | +| `nR` | T1, T2a, T2b | `ι → ℕ` | +| `dR` | T1, T2a, T2b | `ι → ℕ → ℕ` | +| `hmono` | T1, T2a, T2b | `∀ r ∈ R, ∀ i < nR r, dR r i ≤ dR r (i + 1)` | +| `hd9` | T1, T2a, T2b | `∀ r ∈ R, dR r (nR r) ≤ 9` | +| `hmix` | T1, T2a, T2b | `(R.filter fun r => Mixed dR nR r).card ≤ 5` | +| `n` | T1, T2a, T2b | `Inv` | +| `ks` | T1, T2a, T2b | `List ℕ` | +| `mr st` | T1, T2a, T2b | `ℕ` | +| `E` | T1, T2a, T2b | `ℝ → ℝ` | +| `J` | T1, T2a, T2b | `Finset (ℕ × ℕ)` | +| `distF` | T1, T2a, T2b | `ℝ → ℕ × ℕ → ℝ` | +| `spF cstF` | T1, T2a, T2b | `ℝ → ℝ` | +| `hk` | T1, T2a, T2b | `∀ k ∈ ks, 1 ≤ k ∧ k ≤ 9` | +| `hmass` | T1, T2a, T2b | `56 ≤ ks.sum` | +| `hmd` | T1, T2a, T2b | `8 ≤ ks.length` | +| `hmr` | T1, T2a, T2b | `8 ≤ mr` | +| `hF` | T1, T2a, T2b | `∀ s, 0 ≤ s → s ≤ 1 → Finv s n ≤ -400 * (8 : ℝ) ^ s - dprice ks s - mr - E s` | +| `hY` | T1, T2a, T2b | `104 ≤ st + (ks.length + mr)` | +| `hst` | T1, T2a, T2b | `∀ s, 0 ≤ s → s ≤ 1 → (2 - (2 : ℝ) ^ s) * st ≤ E s` | +| `hEex` | T1, T2a, T2b | `∀ s, 0 ≤ s → s ≤ 1 → ∑ r ∈ R, ex (gs s) (lev dR r) (nR r) ≤ E s` | +| `hcong` | T1, T2a, T2b | `∀ s, 9 / 10 ≤ s → s ≤ 1 - ((tJ0 : ℚ) : ℝ) → ∑ p ∈ J, min (distF s p) (capC s) - corrC cstF s ≤ ∑ r ∈ R, ∑ i ∈ range (nR r), c2 (gs s) (lev dR r i) (lev dR r (i + 1)) + Omega ks mr s (differs between theorems; see PROVED.md)` | +| `hdist` | T1, T2a, T2b | `∀ s, 9 / 10 ≤ s → s ≤ 1 - ((tJ0 : ℚ) : ℝ) → ∀ p ∈ J, spF (1 - s) ≤ distF s p (differs between theorems; see PROVED.md)` | +| `hJ` | T1 | `4962 ≤ J.card` | +| `hspMono` | T1, T2a, T2b | `MonotoneOn spF (Set.Icc ((tJ0 : ℚ) : ℝ) (1 / 10)) (differs between theorems; see PROVED.md)` | +| `hcstMono` | T1, T2a, T2b | `MonotoneOn cstF (Set.Icc ((tJ0 : ℚ) : ℝ) (1 / 10)) (differs between theorems; see PROVED.md)` | +| `hspTab` | T1 | `((spFloC0 : ℚ) : ℝ) ≤ spF ((tC0 : ℚ) : ℝ) ∧ ((spFloC1 : ℚ) : ℝ) ≤ spF ((tC1 : ℚ) : ℝ) ∧ ((spFloC2 : ℚ) : ℝ) ≤ spF ((tC2 : ℚ) : ℝ) ∧ ((spFloC3 : ℚ) : ℝ) ≤ spF ((tC3 : ℚ) : ℝ)` | +| `hcstTab` | T1 | `cstF ((tC1 : ℚ) : ℝ) ≤ ((cHC0 : ℚ) : ℝ) ∧ cstF ((tC2 : ℚ) : ℝ) ≤ ((cHC1 : ℚ) : ℝ) ∧ cstF ((tC3 : ℚ) : ℝ) ≤ ((cHC2 : ℚ) : ℝ) ∧ cstF (1 / 10) ≤ ((cHC3 : ℚ) : ℝ)` | +| `hspTabJ` | T1 | `((spFloJ0 : ℚ) : ℝ) ≤ spF ((tJ0 : ℚ) : ℝ) ∧ ((spFloJ1 : ℚ) : ℝ) ≤ spF ((tJ1 : ℚ) : ℝ) ∧ ((spFloJ2 : ℚ) : ℝ) ≤ spF ((tJ2 : ℚ) : ℝ)` | +| `hcstTabJ` | T1 | `cstF ((tJ1 : ℚ) : ℝ) ≤ ((cHJ0 : ℚ) : ℝ) ∧ cstF ((tJ2 : ℚ) : ℝ) ≤ ((cHJ1 : ℚ) : ℝ) ∧ cstF ((tC0 : ℚ) : ℝ) ≤ ((cHJ2 : ℚ) : ℝ)` | +| `m` | T2a | `JunkLawA.LawAModel K 104 D` | +| `hD` | T2a | `D ≤ 56` | +| `hJdef` | T2a | `J = JunkLawA.junkSet m.M` | +| `hspTabN` | T2a, T2b | `((spFloN0 : ℚ) : ℝ) ≤ spF ((tN0 : ℚ) : ℝ) ∧ ((spFloN1 : ℚ) : ℝ) ≤ spF ((tN1 : ℚ) : ℝ) ∧ ((spFloN2 : ℚ) : ℝ) ≤ spF ((tN2 : ℚ) : ℝ) ∧ ((spFloN3 : ℚ) : ℝ) ≤ spF ((tN3 : ℚ) : ℝ) ∧ ((spFloN4 : ℚ) : ℝ) ≤ spF ((tN4 : ℚ) : ℝ) (differs between theorems; see PROVED.md)` | +| `hcstTabN` | T2a, T2b | `cstF ((tN1 : ℚ) : ℝ) ≤ ((cHN0 : ℚ) : ℝ) ∧ cstF ((tN2 : ℚ) : ℝ) ≤ ((cHN1 : ℚ) : ℝ) ∧ cstF ((tN3 : ℚ) : ℝ) ≤ ((cHN2 : ℚ) : ℝ) ∧ cstF ((tN4 : ℚ) : ℝ) ≤ ((cHN3 : ℚ) : ℝ) ∧ cstF ((tN5 : ℚ) : ℝ) ≤ ((cHN4 : ℚ) : ℝ) (differs between theorems; see PROVED.md)` | + +## Files +| file | content | +|---|---| +| PROVED.md | the main statements, copied by script from the Lean text (all hypotheses visible) | +| NATIVES.md | table premise x word (st1, #7637, x1t2a, #7660 word) -> result and script | +| CHECK.txt | fresh compile table of the 66 modules (one at a time, 3.5 GB guard), with one stated exception, and `#print axioms` | +| PR_BODY.md | draft PR description | +| LICENSE | Apache-2.0 | +| lean/ | Lean subproject; sources in `lean/Nov15/`, notes in the per-file `.md` where present | + +## Pins and build +Toolchain `leanprover/lean4:v4.33.0-rc1` (`lean/lean-toolchain`); Mathlib commit `55b7917b472489c7c56a0fa6393af05cfd536599` (`lean/lakefile.toml`, `lean/lake-manifest.json`). +``` +cd lean +lake exe cache get +lake build +``` +CHECK.txt was produced file by file with `lean -j1 -o` in dependency order against an existing build of the pinned Mathlib, with a fresh output directory first on the search path. `lake build` itself was not run. + +## Not included +All scripts that compute the word-level premises and the table entries, the word files, and the working notes that the per-file `.md` notes cite. Labels such as HC5 or JL1 refer to those notes. diff --git a/research/p104-tiered-ceiling/lean/Nov15/CallerCost.lean b/research/p104-tiered-ceiling/lean/Nov15/CallerCost.lean new file mode 100644 index 0000000000..644e5b918d --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/CallerCost.lean @@ -0,0 +1,279 @@ +/- +CALLER-COST . Closed form of the CALLERCO caller invoice (internal notes `caller`, ck.py), +histograms as lists of (rank, count) terms, S = sum r*(T-P), D0 = sum (T-P)*f(r), f r = r ln r (FloorD0 convention), +invoice = caller + calls * native, reproduction of the #7113 caller at 8|9, S(k) = 3408 k - 208, single-crossing in the native +D0 per call, and the abstract composition lemma. Kernel only, no sorry / native_decide. +-/ +import Mathlib.Analysis.SpecialFunctions.Log.Basic +import Mathlib.Algebra.BigOperators.Group.Finset.Basic +import Mathlib.Algebra.Order.BigOperators.Group.Finset +import Mathlib.Tactic + +namespace CallerCost +open Real + +/-- a histogram: list of (rank, count) terms -/ +abbrev Hist := List (ℕ × ℕ) + +def cnt (l : Hist) (r : ℕ) : ℕ := (l.map fun p => if p.1 = r then p.2 else 0).sum +def Sh (l : Hist) : ℤ := (l.map fun p => (p.1 : ℤ) * p.2).sum +noncomputable def fL (r : ℕ) : ℝ := (r : ℝ) * Real.log r +noncomputable def Dh (l : Hist) : ℝ := (l.map fun p => (p.2 : ℝ) * fL p.1).sum +def scale (L : ℕ) (l : Hist) : Hist := l.map fun p => (p.1, L * p.2) + +structure Inv where + T : Hist + P : Hist + +def Sinv (i : Inv) : ℤ := Sh i.T - Sh i.P +noncomputable def Dinv (i : Inv) : ℝ := Dh i.T - Dh i.P +/-- invoice = caller + L * native (pricekit.invoice, counts scaled by L) -/ +def invoice (c n : Inv) (L : ℕ) : Inv := ⟨c.T ++ scale L n.T, c.P ++ scale L n.P⟩ + +theorem Sh_append (l m : Hist) : Sh (l ++ m) = Sh l + Sh m := by simp [Sh] +theorem Dh_append (l m : Hist) : Dh (l ++ m) = Dh l + Dh m := by simp [Dh] +theorem Sh_scale (L : ℕ) (l : Hist) : Sh (scale L l) = L * Sh l := by + induction l with + | nil => simp [Sh, scale] + | cons p l ih => + simp only [Sh, scale, List.map_cons, List.sum_cons] at ih ⊢ + rw [ih]; push_cast; ring +theorem Dh_scale (L : ℕ) (l : Hist) : Dh (scale L l) = L * Dh l := by + induction l with + | nil => simp [Dh, scale] + | cons p l ih => + simp only [Dh, scale, List.map_cons, List.sum_cons] at ih ⊢ + rw [ih]; push_cast; ring + +theorem invoice_S (c n : Inv) (L : ℕ) : Sinv (invoice c n L) = Sinv c + L * Sinv n := by + simp only [Sinv, invoice, Sh_append, Sh_scale]; ring +theorem invoice_D0 (c n : Inv) (L : ℕ) : Dinv (invoice c n L) = Dinv c + L * Dinv n := by + simp only [Dinv, invoice, Dh_append, Dh_scale]; ring + +/-! ### the caller family C(a|b): g = 8, 96 A ports x 4 thin queries, 8 B ports (s1.py) -/ +def armT (n c : ℕ) : Hist := (List.range n).map fun i => (8 * i + 9, c) +def armP (m c : ℕ) : Hist := (List.range m).map fun i => (8 * i + 16, c) +/-- C(a'+2 | b'+2); stage count k = a'+b'+4. 208 = 2 * 104 ports. -/ +def callerT (a b : ℕ) : Hist := armT (a + 2) 208 ++ armT (b + 2) 208 ++ [(8 * (a + b + 4) + 1, 208)] +def callerP (a b : ℕ) : Hist := + armP a 208 ++ armP b 208 ++ [(8, 384), (1, 384), (8, 16 * (a + b + 4)), (9, 32)] +def caller (a b : ℕ) : Inv := ⟨callerT a b, callerP a b⟩ + +/-- #7113 caller invoice (PRICEKIT caller_invoice of MONOCALLER/7113_CALLER.json), data; nJ = 17 -/ +def dataT : Hist := [(9,416),(17,416),(25,416),(33,416),(41,416),(49,416),(57,416),(65,416),(73,208),(137,208)] +def dataP : Hist := [(1,384),(8,656),(9,32),(16,416),(24,416),(32,416),(40,416),(48,416),(56,416),(64,208)] + +theorem cnt_zero {l : Hist} {r : ℕ} (h : ∀ p ∈ l, p.1 ≠ r) : cnt l r = 0 := by + unfold cnt + apply List.sum_eq_zero + intro x hx + obtain ⟨p, hp, rfl⟩ := List.mem_map.mp hx + simp [h p hp] + +theorem keys_T : ∀ p ∈ callerT 6 7, p.1 < 200 := by decide +theorem keys_P : ∀ p ∈ callerP 6 7, p.1 < 200 := by decide +theorem keys_dT : ∀ p ∈ dataT, p.1 < 200 := by decide +theorem keys_dP : ∀ p ∈ dataP, p.1 < 200 := by decide + +theorem cnt_big {l : Hist} (hl : ∀ p ∈ l, p.1 < 200) {r : ℕ} (hr : 200 ≤ r) : cnt l r = 0 := + cnt_zero fun p hp => by have := hl p hp; omega + +theorem repro_T : ∀ r, cnt (callerT 6 7) r = cnt dataT r := by + intro r + by_cases hr : r < 200 + · interval_cases r <;> decide + · rw [cnt_big keys_T (by omega), cnt_big keys_dT (by omega)] +theorem repro_P : ∀ r, cnt (callerP 6 7) r = cnt dataP r := by + intro r + by_cases hr : r < 200 + · interval_cases r <;> decide + · rw [cnt_big keys_P (by omega), cnt_big keys_dP (by omega)] + +/-- weighted sums depend only on the histogram (keys below N) -/ +theorem wsum_cnt (w : ℕ → ℝ) (N : ℕ) : ∀ l : Hist, (∀ p ∈ l, p.1 < N) → + (l.map fun p => (p.2 : ℝ) * w p.1).sum = ∑ r ∈ Finset.range N, (cnt l r : ℝ) * w r := by + intro l + induction l with + | nil => intro _; simp [cnt] + | cons p l ih => + intro h + have hp : p.1 < N := h p (by simp) + have ih' := ih (fun q hq => h q (by simp [hq])) + have hc : ∀ r, (cnt (p :: l) r : ℝ) = (if p.1 = r then (p.2 : ℝ) else 0) + cnt l r := by + intro r; simp only [cnt, List.map_cons, List.sum_cons]; split_ifs <;> simp + simp only [List.map_cons, List.sum_cons] + rw [ih'] + simp only [hc, add_mul, Finset.sum_add_distrib] + congr 1 + rw [Finset.sum_eq_single p.1] + · simp + · intro b _ hb; simp [Ne.symm hb] + · intro h'; exact absurd (Finset.mem_range.mpr hp) h' + +theorem Dh_congr (l m : Hist) (hl : ∀ p ∈ l, p.1 < 200) (hm : ∀ p ∈ m, p.1 < 200) + (h : ∀ r, cnt l r = cnt m r) : Dh l = Dh m := by + unfold Dh; rw [wsum_cnt fL 200 l hl, wsum_cnt fL 200 m hm] + exact Finset.sum_congr rfl fun r _ => by rw [h r] + +theorem caller89_D0 : + Dh (callerT 6 7) = Dh dataT ∧ Dh (callerP 6 7) = Dh dataP := + ⟨Dh_congr _ _ keys_T keys_dT repro_T, Dh_congr _ _ keys_P keys_dP repro_P⟩ + +theorem caller89_S : Sh (callerT 6 7) = Sh dataT ∧ Sh (callerP 6 7) = Sh dataP := by + constructor <;> decide + +/-- REPRODUCTION: C(8|9) equals the #7113 caller invoice (histograms term for term; hence S and D0). -/ +theorem reproduction : + (∀ r, cnt (caller 6 7).T r = cnt dataT r) ∧ (∀ r, cnt (caller 6 7).P r = cnt dataP r) ∧ + Sinv (caller 6 7) = Sh dataT - Sh dataP ∧ Dinv (caller 6 7) = Dh dataT - Dh dataP := by + refine ⟨repro_T, repro_P, ?_, ?_⟩ + · simp only [Sinv, caller, caller89_S.1, caller89_S.2] + · simp only [Dinv, caller, caller89_D0.1, caller89_D0.2] + +theorem S_data : Sh dataT - Sh dataP = 57728 := by decide + +/-! ### closed forms -/ +theorem Sh_armT (n c : ℕ) : Sh (armT n c) = c * (4 * n * n + 5 * n) := by + induction n with + | zero => simp [armT, Sh] + | succ n ih => + have : armT (n + 1) c = armT n c ++ [(8 * n + 9, c)] := by simp [armT, List.range_succ] + rw [this, Sh_append, ih]; simp [Sh]; push_cast; ring +theorem Sh_armP (m c : ℕ) : Sh (armP m c) = c * (4 * m * m + 12 * m) := by + induction m with + | zero => simp [armP, Sh] + | succ n ih => + have : armP (n + 1) c = armP n c ++ [(8 * n + 16, c)] := by simp [armP, List.range_succ] + rw [this, Sh_append, ih]; simp [Sh]; push_cast; ring + +/-- caller S is affine in the stage count k = a+b+4: S = 3408 k - 208 (96 A + 8 B ports; both arms >= 2) -/ +theorem S_caller (a b : ℕ) : Sinv (caller a b) = 3408 * ((a : ℤ) + b + 4) - 208 := by + simp only [Sinv, caller, callerT, callerP, Sh_append, Sh_armT, Sh_armP] + simp [Sh]; push_cast; ring + +/-- S of the whole invoice with calls = k: (3408 + Sn) k - 208 -/ +theorem S_invoice (a b : ℕ) (n : Inv) : + Sinv (invoice (caller a b) n (a + b + 4)) = (3408 + Sinv n) * ((a : ℤ) + b + 4) - 208 := by + rw [invoice_S, S_caller]; push_cast; ring + +/-- with the #7630 native (S per call = -3312, from S = 1424 at k = 17): S(k) = 96 k - 208 -/ +theorem S_7630 (a b : ℕ) (n : Inv) (hn : Sinv n = -3312) : + Sinv (invoice (caller a b) n (a + b + 4)) = 96 * ((a : ℤ) + b + 4) - 208 := by + rw [S_invoice, hn]; ring + +theorem S_7630_k17 (n : Inv) (hn : Sinv n = -3312) : + Sinv (invoice (caller 6 7) n 17) = 1424 := by + have := S_7630 6 7 n hn; simpa using this + +theorem Dh_armT (n c : ℕ) : Dh (armT n c) = c * ∑ i ∈ Finset.range n, fL (8 * i + 9) := by + induction n with + | zero => simp [armT, Dh] + | succ n ih => + have : armT (n + 1) c = armT n c ++ [(8 * n + 9, c)] := by simp [armT, List.range_succ] + rw [this, Dh_append, ih, Finset.sum_range_succ]; simp [Dh]; ring +theorem Dh_armP (n c : ℕ) : Dh (armP n c) = c * ∑ i ∈ Finset.range n, fL (8 * i + 16) := by + induction n with + | zero => simp [armP, Dh] + | succ n ih => + have : armP (n + 1) c = armP n c ++ [(8 * n + 16, c)] := by simp [armP, List.range_succ] + rw [this, Dh_append, ih, Finset.sum_range_succ]; simp [Dh]; ring + +theorem fL_one : fL 1 = 0 := by simp [fL] + +/-- caller D0 (the stage-count cost C(k), exact): the sums are over the ranks 8j+1 (T) and 8j (P) -/ +theorem D0_caller (a b : ℕ) : Dinv (caller a b) = + 208 * (∑ i ∈ Finset.range (a + 2), fL (8 * i + 9) + ∑ i ∈ Finset.range (b + 2), fL (8 * i + 9) + + fL (8 * (a + b + 4) + 1) + - ∑ i ∈ Finset.range a, fL (8 * i + 16) - ∑ i ∈ Finset.range b, fL (8 * i + 16)) + - (384 + 16 * ((a : ℝ) + b + 4)) * fL 8 - 32 * fL 9 := by + simp only [Dinv, caller, callerT, callerP, Dh_append, Dh_armT, Dh_armP] + simp [Dh, fL_one]; ring + +/-! ### single crossing: a cheaper native can only lower the best stage count (first-order proxy K = S/D0) -/ +section crossing +variable {s ρ Dc1 Dc2 k1 k2 d d' : ℝ} + +/-- proxy objective K_d(k) = S(k) / (Dc(k) + k d), S(k) = s k - ρ, d = native D0 per call, calls = k -/ +theorem single_crossing (hρ : 0 < ρ) (hk : k1 ≤ k2) (hd : d ≤ d') + (hD1 : 0 < Dc1 + k1 * d) (hD2 : 0 < Dc2 + k2 * d) + (hD1' : 0 < Dc1 + k1 * d') (hD2' : 0 < Dc2 + k2 * d') + (h : (s * k1 - ρ) / (Dc1 + k1 * d) ≤ (s * k2 - ρ) / (Dc2 + k2 * d)) : + (s * k1 - ρ) / (Dc1 + k1 * d') ≤ (s * k2 - ρ) / (Dc2 + k2 * d') := by + rw [div_le_div_iff₀ hD1 hD2] at h + rw [div_le_div_iff₀ hD1' hD2'] + have : 0 ≤ (d' - d) * (ρ * (k2 - k1)) := mul_nonneg (by linarith) (mul_nonneg hρ.le (by linarith)) + nlinarith + +/-- contrapositive form: if at the costlier native the smaller k is (weakly) preferred, it is at the cheaper native too; + equivalently the best k never goes up when D0 per call goes down -/ +theorem cheaper_native_lowers_k (hρ : 0 < ρ) (hk : k1 ≤ k2) (hd : d ≤ d') + (hD1 : 0 < Dc1 + k1 * d) (hD2 : 0 < Dc2 + k2 * d) + (hD1' : 0 < Dc1 + k1 * d') (hD2' : 0 < Dc2 + k2 * d') + (h : (s * k2 - ρ) / (Dc2 + k2 * d') < (s * k1 - ρ) / (Dc1 + k1 * d')) : + (s * k2 - ρ) / (Dc2 + k2 * d) < (s * k1 - ρ) / (Dc1 + k1 * d) := by + by_contra hn + exact absurd (single_crossing hρ hk hd hD1 hD2 hD1' hD2' (not_lt.mp hn)) (not_le.mpr h) + +/-- the crossing native D0 per call at which k1 and k2 tie (proxy): d* = (S1 Dc2 - S2 Dc1) / (ρ (k2 - k1)) -/ +theorem crossing_value (hρ : 0 < ρ) (hk : k1 < k2) : + (s * k1 - ρ) * (Dc2 + k2 * d) = (s * k2 - ρ) * (Dc1 + k1 * d) ↔ + d = ((s * k1 - ρ) * Dc2 - (s * k2 - ρ) * Dc1) / (ρ * (k2 - k1)) := by + have hne : ρ * (k2 - k1) ≠ 0 := (mul_pos hρ (by linarith)).ne' + rw [eq_div_iff hne] + constructor <;> intro h <;> nlinarith + +/-- sensitivity: d/dd of the stationarity numerator N = S'D - SD' (D = Dc + k d) is k S' - S = rho > 0. + (CALLERCO R1 sec 3 writes -(kS'-S); the sign convention there is reversed, the conclusion "cheaper native -> smaller k" is the same.) -/ +theorem stationarity_slope (s ρ Dc Dc' k d : ℝ) : + (s * (Dc + k * d) - (s * k - ρ) * (Dc' + d)) = (s * Dc - (s * k - ρ) * Dc') + ρ * d := by ring +end crossing + +/-! ### composition: invoice D0 >= caller floor + calls * native floor -/ +section composition +variable {Cl : Type} + +/-- Abstract composition. A caller class Cl with D0 cost Dc and call count `calls`; native per-call D0 Dn. + hc: caller floor as a function of the number of calls it makes; hn: a floor on the TOTAL native D0 per call. -/ +theorem composition (Dc : Cl → ℝ) (calls : Cl → ℕ) (Fc : ℕ → ℝ) (Dn Fn : ℝ) + (hc : ∀ c, Fc (calls c) ≤ Dc c) (hn : Fn ≤ Dn) (c : Cl) : + Fc (calls c) + calls c * Fn ≤ Dc c + calls c * Dn := by + have := hc c + have : (calls c : ℝ) * Fn ≤ calls c * Dn := mul_le_mul_of_nonneg_left hn (Nat.cast_nonneg _) + linarith + +/-- the native's D0 per call splits as helperD0 + rest (mains and owned MOVEs; these are CREDITS, rest <= 0 on #7630). + The helper-only floor therefore needs a cap R on the credits: rest >= -R. -/ +theorem composition_helper (Dc : Cl → ℝ) (calls : Cl → ℕ) (Fc : ℕ → ℝ) (H rest Hf R : ℝ) + (hc : ∀ c, Fc (calls c) ≤ Dc c) (hH : Hf ≤ H) (hR : -R ≤ rest) (c : Cl) : + Fc (calls c) + calls c * (Hf - R) ≤ Dc c + calls c * (H + rest) := + composition Dc calls Fc (H + rest) (Hf - R) hc (by linarith) c + +/-- the proxy kappa is bounded by S / (floor) when the floor is positive -/ +theorem kappa_proxy_le {S D F : ℝ} (hS : 0 ≤ S) (hF : 0 < F) (hFD : F ≤ D) : S / D ≤ S / F := + div_le_div_of_nonneg_left hS hF hFD + +/-- FALSE AS WRITTEN: "invoice D0 >= caller D0 + calls * helperD0-floor" (helper floor 9,928.76 per call on #7630, + caller D0 270,813, calls 17, invoice D0 391,295.63 (R1 sec 2; numbers are hypotheses/data)). The missing term is the + mains/owned MOVE credits (negative D0). Counterexample: -/ +theorem naive_composition_false : + ¬ ((270813 : ℝ) + 17 * 9928.76 ≤ 391295.63) := by norm_num + +/-- the credits implied by the data: rest per call = (391295.63 - 270813)/17 - 9928.76 < 0 -/ +theorem rest_negative : (391295.63 - 270813 : ℝ) / 17 - 9928.76 < 0 := by norm_num + +end composition + +#print axioms reproduction +#print axioms S_caller +#print axioms S_7630_k17 +#print axioms D0_caller +#print axioms invoice_S +#print axioms invoice_D0 +#print axioms single_crossing +#print axioms cheaper_native_lowers_k +#print axioms crossing_value +#print axioms composition +#print axioms composition_helper +#print axioms naive_composition_false + +end CallerCost diff --git a/research/p104-tiered-ceiling/lean/Nov15/CallerCost.md b/research/p104-tiered-ceiling/lean/Nov15/CallerCost.md new file mode 100644 index 0000000000..da373369e1 --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/CallerCost.md @@ -0,0 +1,18 @@ +# CallerCost.lean: caller cost closed form, reproduction, single crossing, composition +Imports Mathlib only (no Nov15 deps).9 GB. 12 `#print axioms` within [propext, Classical.choice, Quot.sound]; no sorry, no native_decide. + +## Model +- Histograms = lists of (rank,count). S = sum r*(T-P) (Sinv), D0 = sum (T-P) f(r), f r = r ln r (fL, FloorD0 convention). invoice c n L = caller + L*native (counts scaled), `invoice_S`, `invoice_D0` exact. In the pricer the number of calls L = nJ = k = a+b (stage count). +- Caller family C(a|b), g=8, 96 A ports x 4 thin queries, 8 B ports (a,b >= 2; Lean params a'=a-2, b'=b-2, k = a'+b'+4). T: ranks 8j+1, j<=arm (and 8k+1), 208 = 2*104 each; P: ranks 8j, 2<=j<=arm-1, plus (8: 384+16k, 1: 384, 9: 32). +- The code does NOT use a Z^4 over ln 2/3/5/7 form (it works in Decimal over all ranks up to 137, which involve many primes). Exact form in Lean: `D0_caller`, a finite sum of f over the ranks 8j+1 and 8j, minus (384+16k) f(8) + 32 f(9) (f(1)=0). + +## Proved +- `reproduction`: C(8|9) = caller 6 7 equals the #7113 caller invoice (data lists dataT/dataP, transcribed from the pricer's invoice of the #7113 caller file) term for term as histograms (cnt equal at every rank), hence S and D0 equal (`caller89_S`, `caller89_D0`). S = 57728 (`S_data`). Data are transcribed; the Lean statement is about those lists. +- `S_caller`: S(caller) = 3408 k - 208. `S_invoice`: with calls = k, S = (3408 + S_n) k - 208. `S_7630`: S_n = -3312 gives 96 k - 208, and `S_7630_k17` gives 1424 (S' = 96, rho = 208 as in R1 sec 3). +- Single crossing (first-order proxy K = S/D0, S = sk - rho, D = Dc(k) + k d): `single_crossing`: for k1 <= k2, d <= d', K_d(k1) <= K_d(k2) implies K_d'(k1) <= K_d'(k2). `cheaper_native_lowers_k`: strict contrapositive, a cheaper native (d down) never favours a larger k. `crossing_value`: tie at d* = (S1 Dc2 - S2 Dc1)/(rho (k2-k1)). Convexity of C(k) not attempted (not clean: arm terms are sums of r ln r over unequal strides). +- `composition`: abstract caller class, caller floor Fc(calls) <= Dc, total native floor Fn <= Dn gives Fc(k) + k Fn <= invoice D0. `composition_helper`: with native D0 = helperD0 + rest, needs a cap rest >= -R on the mains/owned credits. `kappa_proxy_le`: S/D <= S/F. + +## Statements false / imprecise +1. FALSE as written: "invoice D0 >= caller floor + calls * (helperD0 floor)". With the numbers of the caller-floor note (helper floor 9,928.76 per call as helper D0 on #7630, caller D0 270,813 = 666,499 - 395,686, 17 calls, invoice D0 391,295.63): 270,813 + 17*9,928.76 = 439,602 > 391,296 (`naive_composition_false`). Reason: the native's main/owned MOVEs are credits (negative D0, `rest_negative`: about -2,842 per call). FloorD0's floor is on helperD0 only. Corrected: `composition` with a floor on TOTAL native D0 per call, or `composition_helper` with an explicit credit cap R. A caller-floor statement needs one of these. +2. Sign slip in the caller-ceiling note, section 3: d/dd of the numerator S'D - SD' is +(kS' - S) = +rho (`stationarity_slope`), not -rho. The conclusion (cheaper native lowers k*) is unchanged. +3. Scope: monotonicity is for the proxy S/D0 (kappa ~ S/D), not the exact root kappa of F(t) = 0; the exact-kappa version is not proved here. diff --git a/research/p104-tiered-ceiling/lean/Nov15/CongestionI3.lean b/research/p104-tiered-ceiling/lean/Nov15/CongestionI3.lean new file mode 100644 index 0000000000..3088163ca8 --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/CongestionI3.lean @@ -0,0 +1,377 @@ +import Nov15.CongestionI3Cfg +import Nov15.CongestionI3Mu +import Nov15.CongestionI3NumA +import Nov15.CongestionI3NumC4 +import Nov15.WholeFloorCover +import Mathlib.Analysis.Convex.SpecificFunctions.Pow +import Mathlib.Analysis.Convex.SpecificFunctions.Basic +import Mathlib.Analysis.SpecialFunctions.Log.Base + +/-! +CONGESTION-I3 : the I3 congestion bound and F1's restricted-class ceilings (internal notes: F1.md, +AUDIT.md, LIFT1.md, AUDIT-LIFT.md, LIFT2.md; JUNKINT I3). See CongestionI3.md for the scope list. Kernel only: no sorry, no native_decide. + +Sections: 1 per-pair bound (I3 is a HYPOTHESIS `I3Path`, in model M_V; the shape-DAG minimum is a data hypothesis), 2 forced junk >= 1936 +(kernel-checked configurations + census; per-chain flag-DP minima are a data hypothesis), 3 combination with R3 by MAX, 4 the ceilings. +-/ +namespace CongestionI3 +open NumCertK JointCeiling CallerCost + +/-! ### 1. I3: public excess >= per-pair distance, summed over supp J -/ + +/-- JUNKINT I3 (F1.md sec. 1): in model M_V (every public register except the Y mains ends at V; owned code fixed; X_q born at A_q) the public +excess `E` over R3's per-register floors is at least the sum over the junk pairs of the shortest-path distance. NOT derived here (the +telescoping I1/I2 and the path bound are not formalised): it is the hypothesis `I3Path`, always taken together with its scope. -/ +def I3Path (J : Finset (ℕ × ℕ)) (dist : ℕ × ℕ → ℝ) (E : ℝ) : Prop := ∑ p ∈ J, dist p ≤ E + +/-- per-pair minimum => E >= delta * |J| -/ +theorem pair_bound {J : Finset (ℕ × ℕ)} {dist : ℕ × ℕ → ℝ} {E δ : ℝ} (hd : ∀ p ∈ J, δ ≤ dist p) (h : I3Path J dist E) : + δ * J.card ≤ E := by + have := Finset.card_nsmul_le_sum J dist δ hd + rw [nsmul_eq_mul] at this + unfold I3Path at h + linarith + +/-- D0 currency: shape-DAG minimum 0.541495 per even pair (F1 sec. 1, reproduced by the auditor); 1936 pairs give >= 1048.33 D0 per call. -/ +theorem i3_D0_per_call {J : Finset (ℕ × ℕ)} {dist : ℕ × ℕ → ℝ} {E : ℝ} (hd : ∀ p ∈ J, (0.541495 : ℝ) ≤ dist p) + (h : I3Path J dist E) (hJ : 1936 ≤ J.card) : (1048.33 : ℝ) ≤ E := by + have h1 := pair_bound hd h + have h2 : (1936 : ℝ) ≤ J.card := by exact_mod_cast hJ + nlinarith + +/-! ### 2. forced junk >= 1936 pairs per call for rank-8 C = 56 decoders -/ + +def mu (i k : ℕ) : ℕ := (muTab.getD i []).getD k 0 +/-- every configuration's per-chain minima sum to >= 1936 (kernel) -/ +theorem mu_sum : ∀ i < 8, 1936 ≤ ∑ k ∈ Finset.range 8, mu i k := by decide +kernel + +/-- **forced junk >= 1936 pairs** for a rank-8, C = 56 decoder (one of the 8 configurations `i` of `cfgs`). Scope/hypotheses, all explicit: +* `hsub`: the chain-k forced cells `F k` are unique cells of chain k (exactly one chain can touch them; kernel-defined `uniqCells`); +* `hJ`: forced cells lie in supp J (a product forced non-zero on a cell no other chain touches cannot be cancelled); +* `hDP`: the per-chain flag-DP minimum (data, internal notes, python exact DP over the subspace lattice, NOT kernel-checked). +The decoder class itself (rank-8 on P104 labels, C = 56, rigidity M^ = D1 G D2 quoted numerically, enumeration exhaustive = 12,870 subsets) is the +hypothesis `i < 8`. -/ +theorem forced_junk_ge (i : ℕ) (hi : i < 8) (J : Finset (ℕ × ℕ)) (F : ℕ → Finset (ℕ × ℕ)) + (hsub : ∀ k < 8, F k ⊆ uniqCells (cfgs.getD i []) k) (hJ : ∀ k < 8, F k ⊆ J) + (hDP : ∀ k < 8, mu i k ≤ (F k).card) : 1936 ≤ J.card := by + have hdisj : ∀ k ∈ Finset.range 8, ∀ k' ∈ Finset.range 8, k ≠ k' → Disjoint (F k) (F k') := by + intro k hk k' hk' hne + exact (uniqCells_disjoint (cfgs.getD i []) hne).mono (hsub k (Finset.mem_range.mp hk)) (hsub k' (Finset.mem_range.mp hk')) + have h1 : (Finset.range 8).biUnion F ⊆ J := by + intro p hp + obtain ⟨k, hk, hp⟩ := Finset.mem_biUnion.mp hp + exact hJ k (Finset.mem_range.mp hk) hp + have h2 : ((Finset.range 8).biUnion F).card = ∑ k ∈ Finset.range 8, (F k).card := + Finset.card_biUnion (fun k hk k' hk' hne => hdisj k hk k' hk' hne) + have h3 : ∑ k ∈ Finset.range 8, mu i k ≤ ∑ k ∈ Finset.range 8, (F k).card := + Finset.sum_le_sum fun k hk => hDP k (Finset.mem_range.mp hk) + have h4 := mu_sum i hi + calc 1936 ≤ ∑ k ∈ Finset.range 8, (F k).card := le_trans h4 h3 + _ = ((Finset.range 8).biUnion F).card := h2.symm + _ ≤ J.card := Finset.card_le_card h1 + +/-! ### 3. combination with R3: by MAX, not sum -/ + +/-- **F1 floor in F currency (max rule).** The word's public overpay `E` (F currency) is priced by BOTH R3's forced stops (E >= (2 - 2^s) st, +st + mp >= 104 with lat = 0, nested words) and by I3 (E >= I). Both bound the SAME quantity, so the floor is R1/R2's owned 16 plus +`max (88 (2 - 2^s)) I`. I = 0 recovers R3's `-Nfl`. -/ +theorem f1_floor (s : ℝ) (hs0 : 0 ≤ s) (hs1 : s ≤ 1) (mp st : ℕ) (Fn E I : ℝ) + (hF : Fn ≤ -400 * (8 : ℝ) ^ s - mp - E) (hmp : 16 ≤ mp) (hY : 104 ≤ st + mp) + (hst : (2 - (2 : ℝ) ^ s) * st ≤ E) (hI : I ≤ E) : + Fn ≤ -400 * (8 : ℝ) ^ s - 16 - max (88 * (2 - (2 : ℝ) ^ s)) I := by + have hu1 : (1 : ℝ) ≤ (2 : ℝ) ^ s := Real.one_le_rpow (by norm_num) hs0 + have hu2 : (2 : ℝ) ^ s ≤ 2 := by + have := Real.rpow_le_rpow_of_exponent_le (show (1 : ℝ) ≤ 2 by norm_num) hs1 + simpa using this + set c : ℝ := 2 - (2 : ℝ) ^ s with hc + have hc0 : 0 ≤ c := by linarith + have hc1 : c ≤ 1 := by linarith + have hm : (16 : ℝ) ≤ mp := by exact_mod_cast hmp + have hY' : (104 : ℝ) ≤ st + mp := by exact_mod_cast hY + have hst0 : (0 : ℝ) ≤ st := Nat.cast_nonneg _ + have hE0 : 0 ≤ E := le_trans (mul_nonneg hc0 hst0) hst + suffices h : (16 : ℝ) + max (88 * c) I ≤ mp + E by linarith + rcases le_total (88 * c) I with h | h + · rw [max_eq_right h]; linarith + · rw [max_eq_left h] + rcases le_or_gt (mp : ℝ) 104 with h2 | h2 + · have h3 : c * (104 - mp) ≤ c * st := mul_le_mul_of_nonneg_left (by linarith) hc0 + nlinarith + · nlinarith + +/-- the max rule is not a sum rule: both hypotheses hold with E = max and fail for the sum (so `max` is all the two bounds give). -/ +theorem sum_not_implied : ∃ E I R : ℝ, I ≤ E ∧ R ≤ E ∧ ¬ (I + R ≤ E) := ⟨1, 1, 1, le_refl _, le_refl _, by norm_num⟩ + +/-! ### 4. the ceiling kappa <= .0183952347 (8|9) -/ + +/-- the native of F1's relaxation: owned floor `400 * 8^s + 16`, no stops -/ +def natBase : Inv := ⟨[], [(8, 400), (1, 16)]⟩ +theorem natBase_F (s : ℝ) : Finv s natBase = -(400 * (8 : ℝ) ^ s + 16) := by + simp [Finv, natBase, Fh] + +theorem base_eq (s : ℝ) : Finv s (invoice (caller 6 7) natBase 17) = Fc cfB s := by + simp only [Finv, Fh, invoice, caller, callerT, callerP, armT, armP, natBase, scale, Fc, cfB, + List.range_succ, List.range_zero] + norm_num + ring + +/-- tbar = .0183952347 -/ +def tbarA : ℚ := 183952347 / 10 ^ 10 +theorem sA_eq : sA = 1 - tbarA := by unfold sA tbarA; norm_num + +/-- **F1 ceiling, 8|9 (kappa <= .0183952347)** for words in the restricted class, with every hypothesis explicit: +* scope (propositions the caller must supply): `MV` (model M_V), `Rank8C56` (rank-8 decoder, C = 56 on P104 labels, one of the 8 configurations `i`), + `PlaneSep` (no second-plane carrier of plane-1 content) -- under `PlaneSep` fails the junk bound collapses to 0 (F1 f1k2); LIFT1 replaces it by + the public-provenance direction law (see `ceiling_A_noSep`). `nested`: lat = 0 (verifier rule, WholeFloorNest). +* `hI3`: I3 in F currency, `E s >= sum of per-pair F-distances` (hypothesis `I3Path`, valid under the scope); +* `hdist`: per-pair shape-DAG minimum `sigma0 <= sp_F(t)` for t in [tbar, .1] (DATA: f1ceil.spF at tbar; monotone in t numerically, AUDIT: the + convex/superadditive proof of monotonicity was not re-derived); +* `hforced`/`hDP`: section 2 (|J| >= 1936). +Conclusion: F < 0 on the 17-call invoice of the #7113 caller for every t in [tbar, 1] -- the ceiling convention of JointCeiling/WholeFloorCover. -/ +theorem ceiling_A (MV Rank8C56 PlaneSep : Prop) (hMV : MV) (hR : Rank8C56) (hP : PlaneSep) + (n : Inv) (mp st : ℕ) (E : ℝ → ℝ) (J : Finset (ℕ × ℕ)) (distF : ℝ → ℕ × ℕ → ℝ) + (hF : ∀ s, 0 ≤ s → s ≤ 1 → Finv s n ≤ -400 * (8 : ℝ) ^ s - mp - E s) + (hmp : 16 ≤ mp) (hY : 104 ≤ st + mp) + (hst : ∀ s, 0 ≤ s → s ≤ 1 → (2 - (2 : ℝ) ^ s) * st ≤ E s) + (hI3 : MV → Rank8C56 → PlaneSep → ∀ s, 0 ≤ s → s ≤ 1 → I3Path J (distF s) (E s)) + (hdist : ∀ s, 9 / 10 ≤ s → s ≤ ((sA : ℚ) : ℝ) → ∀ p ∈ J, ((sigma0 : ℚ) : ℝ) ≤ distF s p) + (hJ : 1936 ≤ J.card) : + ∀ t : ℝ, ((tbarA : ℚ) : ℝ) ≤ t → t ≤ 1 → Finv (1 - t) (invoice (caller 6 7) n 17) < 0 := by + intro t ht ht1 + have hsA : ((sA : ℚ) : ℝ) = 1 - ((tbarA : ℚ) : ℝ) := by rw [sA_eq]; push_cast; ring + have htb0 : (0 : ℝ) ≤ ((tbarA : ℚ) : ℝ) := by unfold tbarA; norm_num + have hs0 : (0 : ℝ) ≤ 1 - t := by linarith + have htb1 : ((tbarA : ℚ) : ℝ) ≤ 1 / 10 := by unfold tbarA; norm_num + have hs1 : 1 - t ≤ 1 := by linarith + have hu1 : (1 : ℝ) ≤ (2 : ℝ) ^ (1 - t) := Real.one_le_rpow (by norm_num) hs0 + have hu2 : (2 : ℝ) ^ (1 - t) ≤ 2 := by + have := Real.rpow_le_rpow_of_exponent_le (show (1 : ℝ) ≤ 2 by norm_num) hs1; simpa using this + have hE0 : 0 ≤ E (1 - t) := + le_trans (mul_nonneg (by linarith) (Nat.cast_nonneg st)) (hst _ hs0 hs1) + rcases le_or_gt (1 / 10 : ℝ) t with h10 | h10 + · -- t >= .1: R3 (I = 0), then the WholeFloorCover cover + have h1 := f1_floor (1 - t) hs0 hs1 mp st (Finv (1 - t) n) (E (1 - t)) 0 (hF _ hs0 hs1) hmp hY (hst _ hs0 hs1) hE0 + have hc0 : (0 : ℝ) ≤ 88 * (2 - (2 : ℝ) ^ (1 - t)) := by linarith + rw [max_eq_left hc0] at h1 + have h2 := invoice_F (1 - t) (caller 6 7) n 17 + have h3 := invoice_F (1 - t) (caller 6 7) natFloor 17 + have h4 := natFloor_F (1 - t) + have h5 := WholeFloorCover.cover t (by linarith) ht1 + have h6 : Nfl (1 - t) = 400 * (8 : ℝ) ^ (1 - t) + 16 + 88 * (2 - (2 : ℝ) ^ (1 - t)) := rfl + push_cast at h2 h3 + nlinarith + · -- t in [tbar, .1): I3 lift + have hsl : (9 / 10 : ℝ) ≤ 1 - t := by linarith + have hsr : 1 - t ≤ ((sA : ℚ) : ℝ) := by rw [hsA]; linarith + have hsum := pair_bound (hdist _ hsl hsr) (hI3 hMV hR hP _ hs0 hs1) + have hE : (1936 : ℝ) * ((sigma0 : ℚ) : ℝ) ≤ E (1 - t) := by + have : (1936 : ℝ) ≤ J.card := by exact_mod_cast hJ + have h0 : (0 : ℝ) ≤ ((sigma0 : ℚ) : ℝ) := by unfold sigma0; norm_num + nlinarith + have h1 := f1_floor (1 - t) hs0 hs1 mp st (Finv (1 - t) n) (E (1 - t)) (1936 * ((sigma0 : ℚ) : ℝ)) (hF _ hs0 hs1) hmp hY + (hst _ hs0 hs1) hE + have h1' : Finv (1 - t) n ≤ -400 * (8 : ℝ) ^ (1 - t) - 16 - 1936 * ((sigma0 : ℚ) : ℝ) := by + have := le_max_right (88 * (2 - (2 : ℝ) ^ (1 - t))) (1936 * ((sigma0 : ℚ) : ℝ)) + linarith + have h2 := invoice_F (1 - t) (caller 6 7) n 17 + have h3 := invoice_F (1 - t) (caller 6 7) natBase 17 + have h4 := natBase_F (1 - t) + have h5 := cfB_neg (1 - t) hsl hsr + have h6 := base_eq (1 - t) + have h7 : ((liftA : ℚ) : ℝ) = 17 * 1936 * ((sigma0 : ℚ) : ℝ) := by unfold liftA; push_cast; ring + push_cast at h2 h3 + nlinarith + + +/-! ### 5. descent-mass >= 56 charge and the own56 ceiling (kappa <= .0134769139) -/ + +/-- F price of a descent list (owned MOVEs of ranks `k`): sum of k^s -/ +noncomputable def dprice (ks : List ℕ) (s : ℝ) : ℝ := (ks.map fun k : ℕ => ((k : ℕ) : ℝ) ^ s).sum + +/-- concavity chord on [1, 9] -/ +theorem chord_k (s : ℝ) (hs0 : 0 ≤ s) (hs1 : s ≤ 1) (k : ℝ) (hk1 : 1 ≤ k) (hk9 : k ≤ 9) : + 1 + ((9 : ℝ) ^ s - 1) / 8 * (k - 1) ≤ k ^ s := by + have hc := (Real.concaveOn_rpow hs0 hs1).2 (show (1 : ℝ) ∈ Set.Ici 0 by simp) (show (9 : ℝ) ∈ Set.Ici 0 by simp) + (show 0 ≤ (9 - k) / 8 by linarith) (show 0 ≤ (k - 1) / 8 by linarith) (show (9 - k) / 8 + (k - 1) / 8 = 1 by ring) + simp only [smul_eq_mul, Real.one_rpow] at hc + have e : (9 - k) / 8 * 1 + (k - 1) / 8 * 9 = k := by ring + rw [e] at hc + nlinarith + +theorem dprice_ge (s : ℝ) (hs0 : 0 ≤ s) (hs1 : s ≤ 1) (ks : List ℕ) (hk : ∀ k ∈ ks, 1 ≤ k ∧ k ≤ 9) : + ks.length + ((9 : ℝ) ^ s - 1) / 8 * ((ks.sum : ℕ) - ks.length) ≤ dprice ks s := by + induction ks with + | nil => simp [dprice] + | cons a l ih => + have ha := hk a (by simp) + have hl : ∀ k ∈ l, 1 ≤ k ∧ k ≤ 9 := fun k hk' => hk k (by simp [hk']) + have ih := ih hl + have h1 := chord_k s hs0 hs1 (a : ℝ) (by exact_mod_cast ha.1) (by exact_mod_cast ha.2) + simp only [dprice, List.map_cons, List.sum_cons, List.length_cons] at ih ⊢ + simp only [Nat.cast_add, Nat.cast_one] + nlinarith + +/-- 9^s <= 8 * 2^s - 7 on [0,1] (convexity of u -> u^p, p = log_2 9, on [1,2]; equality at s = 0, 1). It gives +`(9 - 9^s)/8 >= 2 - 2^s`: an extra descent move is never cheaper than a forced stop it replaces. -/ +theorem nine_chord (s : ℝ) (hs0 : 0 ≤ s) (hs1 : s ≤ 1) : (9 : ℝ) ^ s ≤ 8 * (2 : ℝ) ^ s - 7 := by + set p : ℝ := Real.logb 2 9 with hp + have h2p : (2 : ℝ) ^ p = 9 := Real.rpow_logb (by norm_num) (by norm_num) (by norm_num) + have hp1 : 1 ≤ p := by + have : (2 : ℝ) ^ (1 : ℝ) ≤ (2 : ℝ) ^ p := by rw [Real.rpow_one, h2p]; norm_num + exact (Real.rpow_le_rpow_left_iff (by norm_num : (1 : ℝ) < 2)).mp this + have hu1 : (1 : ℝ) ≤ (2 : ℝ) ^ s := Real.one_le_rpow (by norm_num) hs0 + have hu2 : (2 : ℝ) ^ s ≤ 2 := by + have := Real.rpow_le_rpow_of_exponent_le (show (1 : ℝ) ≤ 2 by norm_num) hs1; simpa using this + have hc := (convexOn_rpow hp1).2 (show (1 : ℝ) ∈ Set.Ici 0 by simp) (show (2 : ℝ) ∈ Set.Ici 0 by simp) + (show 0 ≤ 2 - (2 : ℝ) ^ s by linarith) (show 0 ≤ (2 : ℝ) ^ s - 1 by linarith) + (show (2 - (2 : ℝ) ^ s) + ((2 : ℝ) ^ s - 1) = 1 by ring) + simp only [smul_eq_mul, Real.one_rpow] at hc + have e : (2 - (2 : ℝ) ^ s) * 1 + ((2 : ℝ) ^ s - 1) * 2 = (2 : ℝ) ^ s := by ring + rw [e, h2p] at hc + have e2 : ((2 : ℝ) ^ s) ^ p = (9 : ℝ) ^ s := by + rw [← Real.rpow_mul (by norm_num), mul_comm, Real.rpow_mul (by norm_num), h2p] + rw [e2] at hc + nlinarith + +/-- **own56 floor (F currency, max rule)**: a rank-8 C = 56 decoder has descent mass >= 56 (hypothesis `hmass`, the F1 premise; descents are owned +MOVEs of rank k in 1..9), at least 8 descents and 8 rises (R1/R2). Charging the descents at their true F price `sum k^s` (>= 6 * 9^s + 2) and the 8 +rises at 1 each gives the floor `-400 8^s - (6 9^s + 10) - max (88 (2 - 2^s)) I`; extra moves beyond 8 + 8 cost at least what the stops they remove +save (`nine_chord`). -/ +theorem own56_floor (s : ℝ) (hs0 : 0 ≤ s) (hs1 : s ≤ 1) (ks : List ℕ) (hk : ∀ k ∈ ks, 1 ≤ k ∧ k ≤ 9) + (hmass : 56 ≤ ks.sum) (hmd : 8 ≤ ks.length) (mr st : ℕ) (hmr : 8 ≤ mr) (Fn E I : ℝ) + (hF : Fn ≤ -400 * (8 : ℝ) ^ s - dprice ks s - mr - E) (hY : 104 ≤ st + (ks.length + mr)) + (hst : (2 - (2 : ℝ) ^ s) * st ≤ E) (hI : I ≤ E) : + Fn ≤ -400 * (8 : ℝ) ^ s - (6 * (9 : ℝ) ^ s + 10) - max (88 * (2 - (2 : ℝ) ^ s)) I := by + have hu1 : (1 : ℝ) ≤ (2 : ℝ) ^ s := Real.one_le_rpow (by norm_num) hs0 + have hu2 : (2 : ℝ) ^ s ≤ 2 := by + have := Real.rpow_le_rpow_of_exponent_le (show (1 : ℝ) ≤ 2 by norm_num) hs1; simpa using this + have h9a : (1 : ℝ) ≤ (9 : ℝ) ^ s := Real.one_le_rpow (by norm_num) hs0 + have h9b : (9 : ℝ) ^ s ≤ 9 := by + have := Real.rpow_le_rpow_of_exponent_le (show (1 : ℝ) ≤ 9 by norm_num) hs1; simpa using this + have hch := nine_chord s hs0 hs1 + have hdp := dprice_ge s hs0 hs1 ks hk + set c : ℝ := 2 - (2 : ℝ) ^ s with hc + have hc0 : 0 ≤ c := by linarith + have hc1 : c ≤ 1 := by linarith + set b : ℝ := ((9 : ℝ) ^ s - 1) / 8 with hb + have hb0 : 0 ≤ b := by rw [hb]; linarith + have hcb : c ≤ 1 - b := by rw [hb, hc]; linarith + have hm : (8 : ℝ) ≤ ks.length := by exact_mod_cast hmd + have hmr' : (8 : ℝ) ≤ mr := by exact_mod_cast hmr + have hmass' : (56 : ℝ) ≤ ((ks.sum : ℕ) : ℝ) := by exact_mod_cast hmass + have hY' : (104 : ℝ) ≤ st + (ks.length + mr) := by exact_mod_cast hY + have hst0 : (0 : ℝ) ≤ st := Nat.cast_nonneg _ + have hE0 : 0 ≤ E := le_trans (mul_nonneg hc0 hst0) hst + have hA : (ks.length : ℝ) + b * (56 - ks.length) ≤ dprice ks s := by + have : b * (56 - ks.length) ≤ b * (((ks.sum : ℕ) : ℝ) - ks.length) := mul_le_mul_of_nonneg_left (by linarith) hb0 + linarith + have e9 : (9 : ℝ) ^ s = 8 * b + 1 := by rw [hb]; ring + rw [e9] + suffices h : (6 * (8 * b + 1) + 10) + max (88 * c) I ≤ dprice ks s + mr + E by linarith + have hx : 0 ≤ ((ks.length : ℝ) - 8) * (1 - b - c) := mul_nonneg (by linarith) (by linarith) + have hy : 0 ≤ ((mr : ℝ) - 8) * (1 - c) := mul_nonneg (by linarith) (by linarith) + have hxb : 0 ≤ ((ks.length : ℝ) - 8) * b := mul_nonneg (by linarith) hb0 + rcases le_total (88 * c) I with h | h + · rw [max_eq_right h] + have hx2 : 0 ≤ ((ks.length : ℝ) - 8) * (1 - b) := mul_nonneg (by linarith) (by linarith) + nlinarith + · rw [max_eq_left h] + have h3 : c * (104 - ks.length - mr) ≤ c * st := mul_le_mul_of_nonneg_left (by linarith) hc0 + nlinarith + +/-- the cap/correction form of I3 without plane separation (LIFT1 sec. 1; HYPOTHESIS, valid under the public-provenance direction law only): +transport by owned rank caps each pair's contribution at `cap` and the 8 relaxation rises save at most `corr`. -/ +def I3Cap (J : Finset (ℕ × ℕ)) (dist : ℕ × ℕ → ℝ) (cap corr E : ℝ) : Prop := ∑ p ∈ J, min (dist p) cap - corr ≤ E + +def tbarC : ℚ := 134769139 / 10 ^ 10 +theorem sC_eq : sC = 1 - tbarC := by unfold sC tbarC; norm_num + +def natBaseC : Inv := ⟨[], [(8, 400), (9, 6), (1, 10)]⟩ +theorem natBaseC_F (s : ℝ) : Finv s natBaseC = -(400 * (8 : ℝ) ^ s + (6 * (9 : ℝ) ^ s + 10)) := by + simp [Finv, natBaseC, Fh] +theorem baseC_eq (s : ℝ) : Finv s (invoice (caller 6 7) natBaseC 17) = Fc cfC s := by + simp only [Finv, Fh, invoice, caller, callerT, callerP, armT, armP, natBaseC, scale, Fc, cfC, + List.range_succ, List.range_zero] + norm_num + ring +theorem base88_eq (s : ℝ) : + Finv s (invoice (caller 6 7) natBaseC 17) - 17 * (88 * (2 - (2 : ℝ) ^ s)) = Fc cfC88 s := by + rw [baseC_eq] + simp only [Fc, cfC, cfC88, List.map_cons, List.sum_cons, List.map_nil, List.sum_nil] + push_cast + simp only [Real.one_rpow] + ring + +/-- **own56 ceiling, 8|9 (kappa <= .0134769139)**: as `ceiling_A` but (i) the descent mass >= 56 of the rank-8 C = 56 decoder is charged +(`own56_floor`), and (ii) plane separation is NOT assumed: the junk lift is the capped, corrected one (`I3Cap`, LIFT1), valid under the +public-provenance direction law `Prov` (LIFT1 (i) junk reflux, (ii) non-monotone owned lifetimes, (iii) >= 9-row/network decoders are OPEN and are +exactly what `Prov`/`Rank8C56` stand for here; rank-8 decoders with C = 57 do not exist and C >= 58 is not covered by the junk bound 1936). +Data hypotheses: `hdist` (per-pair `ell s <= min dist cap`, from sp_F and unit/48), `hLc` (1936 * ell - corr >= 13.64105 on [tbarC, .1], python, +monotone numerically). -/ +theorem ceiling_C (MV Rank8C56 Prov : Prop) (hMV : MV) (hR : Rank8C56) (hP : Prov) + (n : Inv) (ks : List ℕ) (mr st : ℕ) (E cap corr ell : ℝ → ℝ) (J : Finset (ℕ × ℕ)) (distF : ℝ → ℕ × ℕ → ℝ) + (hk : ∀ k ∈ ks, 1 ≤ k ∧ k ≤ 9) (hmass : 56 ≤ ks.sum) (hmd : 8 ≤ ks.length) (hmr : 8 ≤ mr) (hcorr0 : ∀ s, 0 ≤ corr s) + (hF : ∀ s, 0 ≤ s → s ≤ 1 → Finv s n ≤ -400 * (8 : ℝ) ^ s - dprice ks s - mr - E s) + (hY : 104 ≤ st + (ks.length + mr)) + (hst : ∀ s, 0 ≤ s → s ≤ 1 → (2 - (2 : ℝ) ^ s) * st ≤ E s) + (hI3 : MV → Rank8C56 → Prov → ∀ s, 0 ≤ s → s ≤ 1 → I3Cap J (distF s) (cap s) (corr s) (E s)) + (hdist : ∀ s, 9 / 10 ≤ s → s ≤ ((sC : ℚ) : ℝ) → ∀ p ∈ J, ell s ≤ min (distF s p) (cap s)) + (hLc : ∀ s, 9 / 10 ≤ s → s ≤ ((sC : ℚ) : ℝ) → ((LcC : ℚ) : ℝ) ≤ 1936 * ell s - corr s) + (hJ : 1936 ≤ J.card) : + ∀ t : ℝ, ((tbarC : ℚ) : ℝ) ≤ t → t ≤ 1 → Finv (1 - t) (invoice (caller 6 7) n 17) < 0 := by + intro t ht ht1 + have hsC : ((sC : ℚ) : ℝ) = 1 - ((tbarC : ℚ) : ℝ) := by rw [sC_eq]; push_cast; ring + have htb0 : (0 : ℝ) ≤ ((tbarC : ℚ) : ℝ) := by unfold tbarC; norm_num + have htb1 : ((tbarC : ℚ) : ℝ) ≤ 1 / 10 := by unfold tbarC; norm_num + have hs0 : (0 : ℝ) ≤ 1 - t := by linarith + have hs1 : 1 - t ≤ 1 := by linarith + have hu1 : (1 : ℝ) ≤ (2 : ℝ) ^ (1 - t) := Real.one_le_rpow (by norm_num) hs0 + have hu2 : (2 : ℝ) ^ (1 - t) ≤ 2 := by + have := Real.rpow_le_rpow_of_exponent_le (show (1 : ℝ) ≤ 2 by norm_num) hs1; simpa using this + have hE0 : 0 ≤ E (1 - t) := + le_trans (mul_nonneg (by linarith) (Nat.cast_nonneg st)) (hst _ hs0 hs1) + have h2 := invoice_F (1 - t) (caller 6 7) n 17 + have h3 := invoice_F (1 - t) (caller 6 7) natBaseC 17 + have h4 := natBaseC_F (1 - t) + push_cast at h2 h3 + rcases le_or_gt (1 / 10 : ℝ) t with h10 | h10 + · have h1 := own56_floor (1 - t) hs0 hs1 ks hk hmass hmd mr st hmr (Finv (1 - t) n) (E (1 - t)) 0 (hF _ hs0 hs1) hY + (hst _ hs0 hs1) hE0 + have hc0 : (0 : ℝ) ≤ 88 * (2 - (2 : ℝ) ^ (1 - t)) := by linarith + rw [max_eq_left hc0] at h1 + have h5 := cfC88_neg (1 - t) hs0 (by linarith) + have h6 := base88_eq (1 - t) + nlinarith + · have hsl : (9 / 10 : ℝ) ≤ 1 - t := by linarith + have hsr : 1 - t ≤ ((sC : ℚ) : ℝ) := by rw [hsC]; linarith + have hcap := hI3 hMV hR hP _ hs0 hs1 + unfold I3Cap at hcap + have hLc' := hLc _ hsl hsr + have hLcpos : (0 : ℝ) < ((LcC : ℚ) : ℝ) := by unfold LcC; norm_num + have hell : 0 ≤ ell (1 - t) := by have := hcorr0 (1 - t); nlinarith + have hsum : (1936 : ℝ) * ell (1 - t) ≤ ∑ p ∈ J, min (distF (1 - t) p) (cap (1 - t)) := by + have := Finset.card_nsmul_le_sum J (fun p => min (distF (1 - t) p) (cap (1 - t))) (ell (1 - t)) (hdist _ hsl hsr) + rw [nsmul_eq_mul] at this + have hj : (1936 : ℝ) ≤ J.card := by exact_mod_cast hJ + nlinarith + have hE : ((LcC : ℚ) : ℝ) ≤ E (1 - t) := by linarith + have h1 := own56_floor (1 - t) hs0 hs1 ks hk hmass hmd mr st hmr (Finv (1 - t) n) (E (1 - t)) ((LcC : ℚ) : ℝ) (hF _ hs0 hs1) hY + (hst _ hs0 hs1) hE + have h1' : Finv (1 - t) n ≤ -400 * (8 : ℝ) ^ (1 - t) - (6 * (9 : ℝ) ^ (1 - t) + 10) - ((LcC : ℚ) : ℝ) := by + have := le_max_right (88 * (2 - (2 : ℝ) ^ (1 - t))) ((LcC : ℚ) : ℝ) + linarith + have h5 := cfC_neg (1 - t) hsl hsr + have h6 := baseC_eq (1 - t) + have h7 : ((liftC : ℚ) : ℝ) = 17 * ((LcC : ℚ) : ℝ) := by unfold liftC; push_cast; ring + nlinarith + +end CongestionI3 + +#print axioms CongestionI3.forced_junk_ge +#print axioms CongestionI3.f1_floor +#print axioms CongestionI3.ceiling_A +#print axioms CongestionI3.chord_k +#print axioms CongestionI3.dprice_ge +#print axioms CongestionI3.nine_chord +#print axioms CongestionI3.own56_floor +#print axioms CongestionI3.ceiling_C diff --git a/research/p104-tiered-ceiling/lean/Nov15/CongestionI3.md b/research/p104-tiered-ceiling/lean/Nov15/CongestionI3.md new file mode 100644 index 0000000000..f4043c17df --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/CongestionI3.md @@ -0,0 +1,21 @@ +# CongestionI3*.lean: the I3 congestion bound and F1's restricted-class ceilings in Lean +Files (build order, each with `-o .lake/build/lib/lean/Nov15/.olean`, the memory-guarded build script, <= 3.5 GB): CongestionI3Data (11 s), CongestionI3Cfg (121 s / 3.37 GB), CongestionI3Mu (5 s), CongestionI3NumA (35 s / 3.2 GB), CongestionI3NumC1..C4 (34/31/28/17 s, <= 3.2 GB), CongestionI3 (24 s / 3.0 GB). Kernel only: no sorry, no native_decide; every `#print axioms` is within [propext, Classical.choice, Quot.sound]. The numeric files are split only for the memory guard (NumCertK interval checks, as in WholeFloorCoverData). +Sources: internal notes (not included in this package). + +## What is proved (kernel) +- **(1) per pair.** `pair_bound`: per-pair minimum delta => E >= delta |J|; `i3_D0_per_call`: 0.541495 per pair and |J| >= 1936 give >= 1048.33 D0/call. I3 itself is the HYPOTHESIS `I3Path J dist E` (sum of path distances <= public excess, model M_V): the telescoping/path bound is NOT formalised, and the shape-DAG minimum (0.541495 in D0, `sigma0` = 9785438/10^9 <= sp_F(t) in F currency) is a data hypothesis (230-shape DAG, f1ceil.py). +- **(2) forced junk >= 1936.** `cfgs` = the 8 valid rank-8 C = 56 configurations (f1enum, z.z' = 0); kernel: `cfgs_ok` (8 rows each, z.z' = 0 on the F2^9 labels `Ulab`), `cfg_uniq0..7` (every chain of every configuration has exactly 330 unique cells = 2640 per configuration, recomputed from `Ulab`/`Gmask`), `uniqCells_disjoint` (a unique cell belongs to one chain). `forced_junk_ge`: if the forced cells F k of chain k are unique cells (hsub), lie in supp J (hJ) and number >= mu(i,k) (hDP), then |J| >= sum_k mu = 1936 (`mu_sum`, kernel on the table `muTab`, all entries 242, from the per-chain rerun f1dp_chain_*.log; per-config sums reproduce f1dp.log). hDP is the python flag-DP minimum over the subspace lattice: DATA, not kernel-checked (a kernel re-run would be ~64 chain DPs). +- **(3) max, not sum.** `f1_floor`: from hF (F <= -400 8^s - mp - E), mp >= 16, st + mp >= 104 (lat = 0, nested words), E >= (2 - 2^s) st (R3's stops) and E >= I (I3): F <= -400 8^s - 16 - max(88 (2 - 2^s), I). I = 0 is R3's -Nfl. `sum_not_implied` records that the sum is not a consequence (E = max satisfies both bounds). +- **(4a) ceiling 8|9, kappa <= .0183952347.** `ceiling_A`: for t in [tbarA = .0183952347, 1], F(1 - t) < 0 on the 17-call #7113 invoice. t >= .1: f1_floor with I = 0 + WholeFloorCover.cover (R3). t in [tbar, .1): lift 17 * 1936 * sigma0 against `cfB_neg`: three Fup pieces on [.9, .93], dF/ds > 0 on [.93, 1 - tbar] (`Fc_mono`) and F_base(s0) < 17 * 1936 * sigma0 at the endpoint (true F_base(s0) = 322.05830, lift 322.05834; python root .0183952344, so .0183952347 is rounded up). +- **(4b) ceiling with descent mass >= 56, kappa <= .0134769139.** `own56_floor`: descents are owned MOVEs of rank k in 1..9 with sum >= 56 (rank-8 C = 56 premise), >= 8 descents and >= 8 rises: F price sum k^s >= 6 9^s + 2 (`chord_k`, `dprice_ge`: concavity chord on [1,9]); extra moves beyond 8 + 8 cost at least the stops they remove save, by `nine_chord` (9^s <= 8 2^s - 7 on [0,1], convexity of u -> u^(log_2 9); so (9 - 9^s)/8 >= 2 - 2^s). This RE-DERIVES the m-tradeoff at the own56 base, which LIFT1/f1ceil only assume (python charges the fixed 6x9 + 2x1 + 8 rises; the Lean statement shows it is sound). `ceiling_C`: F < 0 on [tbarC = .0134769139, 1]: t >= .1 by cfC88_neg (13 pieces, = base + 88 stops), t in [tbar, .1) by cfC_neg (lift 17 * 13.64105; true F_base(sC) = 231.89777, lift 231.89785). + +## Scope and hypotheses (stated in the theorems; none discharged by the kernel unless marked) +- **M_V**: every public register except Y mains ends at V, owned code fixed, X_q born at A_q (AUDIT (1)). Hypothesis `MV` in `hI3`. NO known native is in M_V (224 of 1,501 public registers end at dim <= 7): the ceilings are NOT a floor on the native class; the control pass (S22/#7641/#7637 under both ceilings) is feasibility only. +- **rank-8, C = 56** decoder on P104 labels, one of the 8 enumerated configurations (index i < 8): exhaustiveness over the 12,870 subsets and rigidity M^ = D1 G D2 are quoted/numerical. LIFT2: C = 57 impossible; C = 58 elementary mixes give junk >= 2093 >= 1936, C = 60 sampled; C >= 59 general X only sampled; >= 9-row and network decoders open. The junk bound 1936 is the min over C = 56 EXACTLY (AUDIT-LIFT (3)): a C >= 58 decoder is not covered. `hJ`/`Rank8C56` carry this. +- **plane separation** (`PlaneSep`, ceiling_A): without it the LB collapses to 0 (f1k2). ceiling_C does not assume it but replaces it by the **public-provenance direction law** `Prov` + the cap/correction inequality `I3Cap` (LIFT1 sec. 1; AUDIT-LIFT (1): holders with owned origin/reflux (i), non-monotone owned lifetimes (ii), >= 9-row/network decoders (iii) are OPEN; the split LB 242 < break-even 578 is a count, not a proof). +- **data hypotheses**: `hdist` (per-pair sp_F lower bound on [tbar, .1]; sp_F increasing in t is numerical, the convex/superadditive proof was not re-derived, AUDIT (1)); `hLc` (N min(sp_F, unit/48) - corr >= 13.64105 on [tbarC, .1]; python lift1c, monotone numerically); `hDP` (flag-DP minima); `corr >= 0`. +- **nested** (lat = 0): `hY : 104 <= st + mp` is Theorem Y with lateral owned MOVEs excluded by the verifier nesting rule (WholeFloorNest); R3's port lemma/Theorem Y and slack-rank independence stay upstream. +- The D0 floor 171,478.76 is not formalised (LIFT1: it does not survive without plane separation: owned mass is a D0 credit). + +## Statements false as written +None found. Two points to read carefully: (a) the sum of I3 and R3's stops is NOT implied (`sum_not_implied`); only max is (F1 uses max). (b) F1.md's "k <= 4" for the joint table is not a restriction (AUDIT: k <= 17), not touched here. The own56 ceiling's R3 trade-off is TRUE (nine_chord). diff --git a/research/p104-tiered-ceiling/lean/Nov15/CongestionI3Cfg.lean b/research/p104-tiered-ceiling/lean/Nov15/CongestionI3Cfg.lean new file mode 100644 index 0000000000..4d50ff918d --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/CongestionI3Cfg.lean @@ -0,0 +1,73 @@ +import Nov15.CongestionI3Data + +/-! +CONGESTION-I3 configuration half . Kernel-checked facts about the 8 rank-8 C=56 decoder configurations +(internal notes sec. 2): z.z' = 0, and the census of the "unique" even cells (cells that exactly one chain can touch). +`dot` = F2 dot product of 9-bit labels; chain k = (z_k, z'_k) (virtual lines 104..119, labels `Ulab`); the chain k's support on the +cell (t, s) (t, s < 104) is G[t, z_k] * G[s, z'_k] (nonzero pattern `Gmask`). +-/ +set_option linter.constructorNameAsVariable false +namespace CongestionI3 + +/-- parity of the 9 low bits -/ +def par (x : ℕ) : ℕ := + let a := (x ^^^ (x >>> 4)) &&& 15 + let b := a ^^^ (a >>> 2) + ((b ^^^ (b >>> 1)) ^^^ (x >>> 8)) &&& 1 +theorem par_test : (List.range 512).all (fun x => par x == ((List.range 9).foldl (fun acc i => acc + (x >>> i) % 2) 0) % 2) = true := by decide +kernel +def dot (a b : ℕ) : ℕ := par (a &&& b) +def lab (i : ℕ) : ℕ := Ulab.getD i 0 +/-- G[t, z] ≠ 0 for t < 104, z in 104..119 -/ +def gnz (t z : ℕ) : Bool := ((Gmask.getD t 0) >>> (z - 104)) % 2 == 1 + +/-- the even cells: t ≠ s, q_t . q_s = 0 -/ +def even (t s : ℕ) : Bool := t != s && dot (lab t) (lab s) == 0 +/-- chains that may touch (t,s): q_t ⊥ z_k and q_s ⊥ z'_k (frames of the chain) -/ +def Kset (c : List (ℕ × ℕ)) (t s : ℕ) : List ℕ := + (List.range c.length).filter fun k => + dot (lab t) (lab (c.getD k (0, 0)).1) == 0 && dot (lab s) (lab (c.getD k (0, 0)).2) == 0 +/-- chains whose product is nonzero at (t,s) -/ +def Tset (c : List (ℕ × ℕ)) (t s : ℕ) : List ℕ := + (List.range c.length).filter fun k => gnz t (c.getD k (0, 0)).1 && gnz s (c.getD k (0, 0)).2 +/-- the unique cells of chain k: even, exactly one chain (k) may touch them, and it does -/ +def isUniq (c : List (ℕ × ℕ)) (k t s : ℕ) : Bool := even t s && Kset c t s == [k] && Tset c t s == [k] +def uniqCells (c : List (ℕ × ℕ)) (k : ℕ) : Finset (ℕ × ℕ) := + (Finset.range 104 ×ˢ Finset.range 104).filter fun p => isUniq c k p.1 p.2 = true + +/-- orthogonality z.z' = 0 for all rows -/ +def cfgOK (c : List (ℕ × ℕ)) : Bool := c.length == 8 && c.all fun p => dot (lab p.1) (lab p.2) == 0 +/-- chain index of every unique cell, one pass over the 104 x 104 cells -/ +def uniqOwners (c : List (ℕ × ℕ)) : List ℕ := + (List.range 104).flatMap fun t => (List.range 104).filterMap fun s => + if even t s then + (match Kset c t s with + | [k] => if Tset c t s == [k] then some k else none + | _ => none) + else none +def uniqCensus (c : List (ℕ × ℕ)) : List ℕ := (List.range 8).map fun k => (uniqOwners c).count k + +theorem cfgs_len : cfgs.length = 8 := by decide +kernel +theorem cfgs_ok : cfgs.all cfgOK = true := by decide +kernel +/-- every chain of every configuration has exactly 330 unique cells (2640 = 8 * 330 per configuration, F1 sec. 2); one theorem per +configuration (kernel memory is per declaration). -/ +theorem cfg_uniq0 : uniqCensus (cfgs.getD 0 []) = List.replicate 8 330 := by decide +kernel +theorem cfg_uniq1 : uniqCensus (cfgs.getD 1 []) = List.replicate 8 330 := by decide +kernel +theorem cfg_uniq2 : uniqCensus (cfgs.getD 2 []) = List.replicate 8 330 := by decide +kernel +theorem cfg_uniq3 : uniqCensus (cfgs.getD 3 []) = List.replicate 8 330 := by decide +kernel +theorem cfg_uniq4 : uniqCensus (cfgs.getD 4 []) = List.replicate 8 330 := by decide +kernel +theorem cfg_uniq5 : uniqCensus (cfgs.getD 5 []) = List.replicate 8 330 := by decide +kernel +theorem cfg_uniq6 : uniqCensus (cfgs.getD 6 []) = List.replicate 8 330 := by decide +kernel +theorem cfg_uniq7 : uniqCensus (cfgs.getD 7 []) = List.replicate 8 330 := by decide +kernel + +theorem uniqCells_disjoint (c : List (ℕ × ℕ)) {k k' : ℕ} (h : k ≠ k') : Disjoint (uniqCells c k) (uniqCells c k') := by + rw [Finset.disjoint_left] + intro p hp hp' + simp only [uniqCells, Finset.mem_filter, isUniq, Bool.and_eq_true, beq_iff_eq] at hp hp' + have := hp.2.1.2.symm.trans hp'.2.1.2 + simp at this + exact h this + +end CongestionI3 + +#print axioms CongestionI3.cfg_uniq7 +#print axioms CongestionI3.uniqCells_disjoint diff --git a/research/p104-tiered-ceiling/lean/Nov15/CongestionI3Data.lean b/research/p104-tiered-ceiling/lean/Nov15/CongestionI3Data.lean new file mode 100644 index 0000000000..4f0921cc87 --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/CongestionI3Data.lean @@ -0,0 +1,26 @@ +import Mathlib.Data.Finset.Basic +import Mathlib.Data.Finset.Card +import Mathlib.Data.Finset.Prod +import Mathlib.Data.Finset.Powerset +import Mathlib.Algebra.BigOperators.Group.Finset.Basic +import Mathlib.Order.Interval.Finset.Nat + +/-! +CONGESTION-I3 data : the 8 valid rank-8 C=56 decoder configurations of internal notes (f1enum.py, z.z'=0), +the F2^9 labels U of the 120 E8 lines (PORTSET geo.py), the nonzero pattern of G[t,z] for t<104, z in 104..119, and the per-chain +flag-DP minima mu (internal notes,b}.log, a rerun of f1dp.py printing per-chain values). +-/ +namespace CongestionI3 + +def Ulab : List ℕ := [11, 19, 35, 131, 259, 13, 21, 37, 69, 133, 261, 41, 73, 265, 49, 145, 161, 193, 321, 385, 14, 22, 38, 70, 134, 26, 74, 138, 50, 146, 274, 194, 322, 386, 28, 44, 140, 84, 148, 276, 100, 292, 196, 324, 388, 56, 88, 152, 168, 296, 200, 328, 392, 112, 176, 304, 208, 336, 400, 224, 352, 416, 508, 506, 502, 494, 478, 446, 382, 254, 505, 501, 493, 477, 445, 381, 253, 499, 475, 443, 379, 251, 487, 471, 439, 375, 247, 463, 431, 367, 239, 415, 351, 223, 319, 191, 81, 98, 164, 262, 268, 273, 280, 290, 42, 266, 25, 137, 7, 67, 448, 104, 76, 82, 162, 97, 289, 127, 52, 491] +def Gmask : List ℕ := [16511, 33780, 7537, 26040, 29106, 34652, 17623, 55890, 36147, 41627, 46737, 6861, 19884, 30222, 55622, 41359, 16138, 26731, 31841, 21449, 39251, 23256, 50269, 37692, 48276, 39495, 21411, 31755, 51017, 49024, 43914, 30308, 25198, 19910, 23908, 50145, 47912, 22283, 30883, 27817, 51598, 61996, 45383, 42317, 35557, 49397, 38804, 47164, 9913, 12979, 29144, 26066, 19066, 51866, 58674, 61752, 45651, 42585, 35313, 11478, 14556, 6004, 7695, 55596, 6579, 55864, 17597, 5084, 15476, 10366, 50979, 1980, 50231, 23218, 3539, 8827, 13937, 49311, 40337, 51952, 58712, 61778, 50059, 23822, 2671, 9671, 12749, 40581, 51684, 58956, 62022, 22369, 30921, 27843, 12200, 15266, 36391, 3757, 58918, 43166, 44834, 46469, 44086, 13583] +def cfgs : List (List (ℕ × ℕ)) := [[(104, 105), (106, 107), (108, 109), (110, 118), (111, 115), (112, 116), (114, 117), (119, 113)], + [(104, 110), (105, 118), (111, 108), (112, 119), (114, 106), (115, 109), (116, 113), (117, 107)], + [(104, 111), (105, 115), (106, 119), (107, 113), (110, 108), (114, 112), (117, 116), (118, 109)], + [(104, 114), (105, 117), (108, 119), (109, 113), (110, 106), (111, 112), (115, 116), (118, 107)], + [(105, 104), (107, 106), (109, 108), (113, 119), (115, 111), (116, 112), (117, 114), (118, 110)], + [(106, 110), (107, 118), (112, 111), (113, 109), (114, 104), (116, 115), (117, 105), (119, 108)], + [(106, 114), (107, 117), (108, 111), (109, 115), (110, 104), (113, 116), (118, 105), (119, 112)], + [(108, 110), (109, 118), (111, 104), (112, 114), (113, 107), (115, 105), (116, 117), (119, 106)]] + +end CongestionI3 diff --git a/research/p104-tiered-ceiling/lean/Nov15/CongestionI3DualAlg.lean b/research/p104-tiered-ceiling/lean/Nov15/CongestionI3DualAlg.lean new file mode 100644 index 0000000000..47362970ba --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/CongestionI3DualAlg.lean @@ -0,0 +1,224 @@ +import Nov15.WordDuality +import Mathlib.Analysis.MeanInequalitiesPow +import Mathlib.Analysis.SpecialFunctions.Pow.NNReal + +/-! +CONGESTION-I3-DUAL, algebra half. Source: internal notes (audited SOUND, i3dual/audit/AUD.md). +Two-sided I3: the excess of one public register is telescoped from the END (h9 charge, needs e = 9) or from the BIRTH (k0 charge, needs d0 = 0); +every move of a non-mixed register carries a charge >= c2 = min (h9, k0), and a mixed register (d0 >= 1, e <= 8) loses at most c2 (d0, e). +Kernel only; no sorry, no native_decide. `g` is an arbitrary price function with g 0 = 0 (instance: `gs s x = x^s`, s = 1 - t). +Nothing numeric here. See CongestionI3Dual.md. +-/ +namespace CongestionI3Dual +open Finset WordDuality + +/-! ### 1. move prices -/ + +/-- end-anchored move price (target V = dim 9): g(b-a) + g(9-b) - g(9-a) -/ +def h9 (g : ℝ → ℝ) (a b : ℝ) : ℝ := g (b - a) + g (9 - b) - g (9 - a) +/-- start-anchored move price (birth {0}): g(b-a) + g(a) - g(b) -/ +def k0 (g : ℝ → ℝ) (a b : ℝ) : ℝ := g (b - a) + g a - g b +/-- the uniform charge of ID1 sec. 1 -/ +def c2 (g : ℝ → ℝ) (a b : ℝ) : ℝ := min (h9 g a b) (k0 g a b) + +/-- the price function of the F currency: x^s on x > 0, and 0 at 0 -/ +noncomputable def gs (s : ℝ) (x : ℝ) : ℝ := if 0 < x then x ^ s else 0 +theorem gs_zero (s : ℝ) : gs s 0 = 0 := by simp [gs] + +/-- x^s is subadditive on [0, inf) for 0 <= s <= 1 -/ +theorem gs_subadd (s : ℝ) (hs0 : 0 ≤ s) (hs1 : s ≤ 1) (x y : ℝ) (hx : 0 ≤ x) (hy : 0 ≤ y) : + gs s (x + y) ≤ gs s x + gs s y := by + have key : (x + y) ^ s ≤ x ^ s + y ^ s := by + have := NNReal.rpow_add_le_add_rpow x.toNNReal y.toNNReal hs0 hs1 + have h3 : ((x.toNNReal + y.toNNReal) ^ s : NNReal) ≤ (x.toNNReal ^ s + y.toNNReal ^ s : NNReal) := this + have h4 := (NNReal.coe_le_coe.mpr h3) + simpa [NNReal.coe_rpow, Real.coe_toNNReal _ hx, Real.coe_toNNReal _ hy] using h4 + unfold gs + by_cases hx0 : 0 < x + · by_cases hy0 : 0 < y + · rw [if_pos hx0, if_pos hy0, if_pos (by linarith)]; exact key + · have : y = 0 := le_antisymm (not_lt.mp hy0) hy + subst this; simp + · have : x = 0 := le_antisymm (not_lt.mp hx0) hx + subst this; simp + +/-- the two prices are >= 0 for a subadditive g with g 0 = 0 on 0 <= a <= b <= 9 -/ +theorem h9_nonneg (g : ℝ → ℝ) (hg : ∀ x y, 0 ≤ x → 0 ≤ y → g (x + y) ≤ g x + g y) (a b : ℝ) (hab : a ≤ b) (hb : b ≤ 9) : + 0 ≤ h9 g a b := by + have := hg (b - a) (9 - b) (by linarith) (by linarith) + have e : b - a + (9 - b) = 9 - a := by ring + rw [e] at this; unfold h9; linarith +theorem k0_nonneg (g : ℝ → ℝ) (hg : ∀ x y, 0 ≤ x → 0 ≤ y → g (x + y) ≤ g x + g y) (a b : ℝ) (ha : 0 ≤ a) (hab : a ≤ b) : + 0 ≤ k0 g a b := by + have := hg (b - a) a (by linarith) ha + have e : b - a + a = b := by ring + rw [e] at this; unfold k0; linarith + +/-- duality at the level of move prices (DU1): the start-anchored price of (a,b) is the end-anchored price of the swapped move +`swapN 9 (a,b) = (9-b, 9-a)` of WordDuality. -/ +theorem k0_eq_h9_swapN (g : ℝ → ℝ) (a b : ℕ) (hb : b ≤ 9) (hab : a ≤ b) : + k0 g a b = h9 g (swapN 9 (a, b)).1 (swapN 9 (a, b)).2 := by + simp only [swapN, k0, h9] + have h1 : (((9 - b : ℕ) : ℕ) : ℝ) = 9 - b := by rw [Nat.cast_sub hb]; norm_num + have h2 : (((9 - a : ℕ) : ℕ) : ℝ) = 9 - a := by rw [Nat.cast_sub (le_trans hab hb)]; norm_num + rw [h1, h2] + have e1 : (9 - (a : ℝ)) - (9 - b) = b - a := by ring + have e2 : (9 : ℝ) - (9 - a) = a := by ring + have e3 : (9 : ℝ) - (9 - b) = b := by ring + rw [e1, e2, e3] + +/-- the dual helper (WordDuality `dualH 9`) has the same move prices: its end-anchored charge list is the start-anchored charge list of the +original (reversed order, equal sum). -/ +theorem dualH_charge (g : ℝ → ℝ) (h : FibreK.Helper) (hs : ∀ s ∈ h.steps, s.2 ≤ 9 ∧ s.1 ≤ s.2) : + (((dualH 9 h).steps).map fun s : ℕ × ℕ => h9 g s.1 s.2).sum = (h.steps.map fun s : ℕ × ℕ => k0 g s.1 s.2).sum := by + simp only [dualH, List.map_reverse, List.sum_reverse, List.map_map] + congr 1 + apply List.map_congr_left + intro s hs' + obtain ⟨h1, h2⟩ := hs s hs' + simp only [Function.comp] + exact (k0_eq_h9_swapN g s.1 s.2 h1 h2).symm + +/-! ### 2. one register: telescoping -/ + +/-- a register path: levels `d 0, ..., d n` (born at `d 0`, ending at `d n`); its excess over R3's floor is +`ex = sum g(gaps) - g(e - d0)` (ID1 sec. 1). -/ +def gsum (g : ℝ → ℝ) (d : ℕ → ℝ) (n : ℕ) : ℝ := ∑ i ∈ range n, g (d (i + 1) - d i) +def ex (g : ℝ → ℝ) (d : ℕ → ℝ) (n : ℕ) : ℝ := gsum g d n - g (d n - d 0) + +/-- end-anchored telescoping: for e = 9 the h9 charges sum to the excess -/ +theorem sum_h9_eq (g : ℝ → ℝ) (hg0 : g 0 = 0) (d : ℕ → ℝ) (n : ℕ) (he : d n = 9) : + ∑ i ∈ range n, h9 g (d i) (d (i + 1)) = ex g d n := by + have t : ∑ i ∈ range n, (g (9 - d (i + 1)) - g (9 - d i)) = g (9 - d n) - g (9 - d 0) := + Finset.sum_range_sub (fun i => g (9 - d i)) n + have h : ∑ i ∈ range n, h9 g (d i) (d (i + 1)) = gsum g d n + ∑ i ∈ range n, (g (9 - d (i + 1)) - g (9 - d i)) := by + unfold h9 gsum; rw [← Finset.sum_add_distrib]; apply Finset.sum_congr rfl; intro i _; ring + rw [h, t, he]; unfold ex + have e : (9 : ℝ) - 9 = 0 := by ring + rw [e, hg0, he]; ring + +/-- start-anchored telescoping: for d0 = 0 the k0 charges sum to the excess -/ +theorem sum_k0_eq (g : ℝ → ℝ) (hg0 : g 0 = 0) (d : ℕ → ℝ) (n : ℕ) (hd : d 0 = 0) : + ∑ i ∈ range n, k0 g (d i) (d (i + 1)) = ex g d n := by + have t : ∑ i ∈ range n, (g (d i) - g (d (i + 1))) = g (d 0) - g (d n) := by + have := Finset.sum_range_sub (fun i => g (d i)) n + have h2 : ∑ i ∈ range n, (g (d i) - g (d (i + 1))) = -∑ i ∈ range n, (g (d (i + 1)) - g (d i)) := by + rw [← Finset.sum_neg_distrib]; apply Finset.sum_congr rfl; intro i _; ring + rw [h2, this]; ring + have h : ∑ i ∈ range n, k0 g (d i) (d (i + 1)) = gsum g d n + ∑ i ∈ range n, (g (d i) - g (d (i + 1))) := by + unfold k0 gsum; rw [← Finset.sum_add_distrib]; apply Finset.sum_congr rfl; intro i _; ring + rw [h, t, hd]; unfold ex + rw [hd, hg0]; ring_nf + +/-- **non-mixed register: every move is charged >= c2 and the charges sum to the excess** (ID1 sec. 1, `charge_V`/`charge_Z`). -/ +theorem nonmixed_charge (g : ℝ → ℝ) (hg0 : g 0 = 0) (d : ℕ → ℝ) (n : ℕ) (h : d n = 9 ∨ d 0 = 0) : + ∃ w : ℕ → ℝ, (∀ i ∈ range n, c2 g (d i) (d (i + 1)) ≤ w i) ∧ ∑ i ∈ range n, w i = ex g d n := by + rcases h with h | h + · exact ⟨fun i => h9 g (d i) (d (i + 1)), fun i _ => min_le_left _ _, sum_h9_eq g hg0 d n h⟩ + · exact ⟨fun i => k0 g (d i) (d (i + 1)), fun i _ => min_le_right _ _, sum_k0_eq g hg0 d n h⟩ + +/-- **the slack of any register** (covers mixed registers, ID1 sec. 2): the c2-charges sum to at most the excess plus c2 of the whole register. +No hypothesis on g or on the levels: pointwise `c2 <= g(gap) - max (g(9-a)-g(9-b), g(b)-g(a))`, and both maxima telescope. -/ +theorem sum_c2_le (g : ℝ → ℝ) (d : ℕ → ℝ) (n : ℕ) : + ∑ i ∈ range n, c2 g (d i) (d (i + 1)) ≤ ex g d n + c2 g (d 0) (d n) := by + have t1 : ∑ i ∈ range n, (g (9 - d (i + 1)) - g (9 - d i)) = g (9 - d n) - g (9 - d 0) := + Finset.sum_range_sub (fun i => g (9 - d i)) n + have t2 : ∑ i ∈ range n, (g (d i) - g (d (i + 1))) = g (d 0) - g (d n) := by + have := Finset.sum_range_sub (fun i => g (d i)) n + have h2 : ∑ i ∈ range n, (g (d i) - g (d (i + 1))) = -∑ i ∈ range n, (g (d (i + 1)) - g (d i)) := by + rw [← Finset.sum_neg_distrib]; apply Finset.sum_congr rfl; intro i _; ring + rw [h2, this]; ring + have A : ∑ i ∈ range n, c2 g (d i) (d (i + 1)) ≤ ex g d n + h9 g (d 0) (d n) := by + have : ∑ i ∈ range n, c2 g (d i) (d (i + 1)) ≤ ∑ i ∈ range n, (g (d (i + 1) - d i) + (g (9 - d (i + 1)) - g (9 - d i))) := by + apply Finset.sum_le_sum; intro i _ + have : c2 g (d i) (d (i + 1)) ≤ h9 g (d i) (d (i + 1)) := min_le_left _ _ + unfold h9 at this; linarith + rw [Finset.sum_add_distrib, t1] at this + unfold ex gsum h9 at *; linarith + have B : ∑ i ∈ range n, c2 g (d i) (d (i + 1)) ≤ ex g d n + k0 g (d 0) (d n) := by + have : ∑ i ∈ range n, c2 g (d i) (d (i + 1)) ≤ ∑ i ∈ range n, (g (d (i + 1) - d i) + (g (d i) - g (d (i + 1)))) := by + apply Finset.sum_le_sum; intro i _ + have : c2 g (d i) (d (i + 1)) ≤ k0 g (d i) (d (i + 1)) := min_le_right _ _ + unfold k0 at this; linarith + rw [Finset.sum_add_distrib, t2] at this + unfold ex gsum k0 at *; linarith + unfold c2 + rcases le_total (h9 g (d 0) (d n)) (k0 g (d 0) (d n)) with h | h + · rw [min_eq_left h]; exact A + · rw [min_eq_right h]; exact B + +/-- non-mixed (born at 0 or ending at 9): c2 of the whole register vanishes -/ +theorem c2_total_nonmixed (g : ℝ → ℝ) (hg0 : g 0 = 0) (a e : ℝ) (h : e = 9 ∨ a = 0) : c2 g a e ≤ 0 := by + unfold c2 + rcases h with h | h + · subst h; have : h9 g a 9 = g 0 := by unfold h9; simp + rw [hg0] at this; exact le_trans (min_le_left _ _) this.le + · subst h; have : k0 g 0 e = g 0 := by unfold k0; simp + rw [hg0] at this; exact le_trans (min_le_right _ _) this.le + +/-! ### 3. many registers: <= m mixed -/ + +section Many +variable {ι : Type*} [DecidableEq ι] + +/-- a register is MIXED if it is born above {0} and ends below V (levels are dims) -/ +def Mixed (d : ι → ℕ → ℕ) (n : ι → ℕ) (r : ι) : Prop := 1 ≤ d r 0 ∧ d r (n r) ≤ 8 +instance (d : ι → ℕ → ℕ) (n : ι → ℕ) (r : ι) : Decidable (Mixed d n r) := by unfold Mixed; infer_instance + +/-- the dim sequence of register `r` as reals -/ +def lev (d : ι → ℕ → ℕ) (r : ι) : ℕ → ℝ := fun i => (d r i : ℝ) + +/-- **summing over registers**: c2-charges of all moves <= total excess + (number of mixed registers) * sigma, where `sigma` bounds c2 of one +mixed register (dims 1 <= a <= b <= 8). -/ +theorem sum_all_c2_le (g : ℝ → ℝ) (hg0 : g 0 = 0) (R : Finset ι) (n : ι → ℕ) (d : ι → ℕ → ℕ) + (hmono : ∀ r ∈ R, ∀ i < n r, d r i ≤ d r (i + 1)) (hd9 : ∀ r ∈ R, d r (n r) ≤ 9) + (m : ℕ) (hm : (R.filter fun r => Mixed d n r).card ≤ m) (σ : ℝ) (hσ0 : 0 ≤ σ) + (hσ : ∀ a b : ℕ, 1 ≤ a → a ≤ b → b ≤ 8 → c2 g (a : ℝ) (b : ℝ) ≤ σ) : + ∑ r ∈ R, ∑ i ∈ range (n r), c2 g (lev d r i) (lev d r (i + 1)) ≤ ∑ r ∈ R, ex g (lev d r) (n r) + m * σ := by + have step : ∀ r ∈ R, ∑ i ∈ range (n r), c2 g (lev d r i) (lev d r (i + 1)) ≤ + ex g (lev d r) (n r) + (if Mixed d n r then σ else 0) := by + intro r hr + have h1 := sum_c2_le g (lev d r) (n r) + have hle : ∀ k ≤ n r, d r 0 ≤ d r k := by + intro k + induction k with + | zero => intro _; exact le_refl _ + | succ k ih => intro hk; exact le_trans (ih (by omega)) (hmono r hr k (by omega)) + have h0e := hle (n r) (le_refl _) + by_cases hmx : Mixed d n r + · rw [if_pos hmx] + have := hσ (d r 0) (d r (n r)) hmx.1 h0e hmx.2 + simp only [lev] at h1 ⊢ + linarith + · rw [if_neg hmx] + have hne : d r (n r) = 9 ∨ d r 0 = 0 := by + unfold Mixed at hmx + have := hd9 r hr + omega + have h2 := c2_total_nonmixed g hg0 (lev d r 0) (lev d r (n r)) + (by + rcases hne with h | h + · left; simp [lev, h] + · right; simp [lev, h]) + simp only [lev] at h1 h2 ⊢ + linarith + calc ∑ r ∈ R, ∑ i ∈ range (n r), c2 g (lev d r i) (lev d r (i + 1)) + ≤ ∑ r ∈ R, (ex g (lev d r) (n r) + (if Mixed d n r then σ else 0)) := Finset.sum_le_sum step + _ = ∑ r ∈ R, ex g (lev d r) (n r) + ∑ r ∈ R, (if Mixed d n r then σ else 0) := Finset.sum_add_distrib + _ ≤ ∑ r ∈ R, ex g (lev d r) (n r) + m * σ := by + have : ∑ r ∈ R, (if Mixed d n r then σ else 0) = ((R.filter fun r => Mixed d n r).card : ℝ) * σ := by + rw [← Finset.sum_filter]; simp + rw [this] + have hm' : ((R.filter fun r => Mixed d n r).card : ℝ) ≤ m := by exact_mod_cast hm + nlinarith + +end Many + +end CongestionI3Dual + +#print axioms CongestionI3Dual.gs_subadd +#print axioms CongestionI3Dual.k0_eq_h9_swapN +#print axioms CongestionI3Dual.dualH_charge +#print axioms CongestionI3Dual.nonmixed_charge +#print axioms CongestionI3Dual.sum_c2_le +#print axioms CongestionI3Dual.sum_all_c2_le diff --git a/research/p104-tiered-ceiling/lean/Nov15/CongestionI3DualCertC0.lean b/research/p104-tiered-ceiling/lean/Nov15/CongestionI3DualCertC0.lean new file mode 100644 index 0000000000..75912b05b7 --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/CongestionI3DualCertC0.lean @@ -0,0 +1,5 @@ +import Nov15.CongestionI3DualSig +namespace CongestionI3Dual +open NumCertK +theorem sigC0 : sigOK (1 - tC1) (1 - tC0) sgC0 = true := by decide +kernel +end CongestionI3Dual diff --git a/research/p104-tiered-ceiling/lean/Nov15/CongestionI3DualCertC1.lean b/research/p104-tiered-ceiling/lean/Nov15/CongestionI3DualCertC1.lean new file mode 100644 index 0000000000..55e0eb46d3 --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/CongestionI3DualCertC1.lean @@ -0,0 +1,5 @@ +import Nov15.CongestionI3DualSig +namespace CongestionI3Dual +open NumCertK +theorem sigC1 : sigOK (1 - tC2) (1 - tC1) sgC1 = true := by decide +kernel +end CongestionI3Dual diff --git a/research/p104-tiered-ceiling/lean/Nov15/CongestionI3DualCertC2.lean b/research/p104-tiered-ceiling/lean/Nov15/CongestionI3DualCertC2.lean new file mode 100644 index 0000000000..87999f43fe --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/CongestionI3DualCertC2.lean @@ -0,0 +1,5 @@ +import Nov15.CongestionI3DualSig +namespace CongestionI3Dual +open NumCertK +theorem sigC2 : sigOK (1 - tC3) (1 - tC2) sgC2 = true := by decide +kernel +end CongestionI3Dual diff --git a/research/p104-tiered-ceiling/lean/Nov15/CongestionI3DualCertC3.lean b/research/p104-tiered-ceiling/lean/Nov15/CongestionI3DualCertC3.lean new file mode 100644 index 0000000000..ae82c32969 --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/CongestionI3DualCertC3.lean @@ -0,0 +1,5 @@ +import Nov15.CongestionI3DualSig +namespace CongestionI3Dual +open NumCertK +theorem sigC3 : sigOK (9 / 10) (1 - tC3) sgC3 = true := by decide +kernel +end CongestionI3Dual diff --git a/research/p104-tiered-ceiling/lean/Nov15/CongestionI3DualConst.lean b/research/p104-tiered-ceiling/lean/Nov15/CongestionI3DualConst.lean new file mode 100644 index 0000000000..192da15a75 --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/CongestionI3DualConst.lean @@ -0,0 +1,43 @@ +import Mathlib.Data.Rat.Defs + +/-! CONGESTION-I3-DUAL constants: t-breakpoints of the pieces, certified sigma_j (Sig/Cert*), data lower bounds lcp_j +(python: internal notes; lcp_j = lower bound of 1936 spF(t_j) [8|9] resp. 1936 min(sp, cap) - 8 cst [own56], rounded down), L_j = lcp_j - 5 sigma_j. -/ +namespace CongestionI3Dual +-- 8|9 plain, m = 5: t-breakpoints +def tA0 : ℚ := 186470 / 10 ^ 7 +def tA1 : ℚ := 186490 / 10 ^ 7 +def tA2 : ℚ := 187490 / 10 ^ 7 +def tA3 : ℚ := 287490 / 10 ^ 7 +-- own56, m = 5 +def tC0 : ℚ := 136564 / 10 ^ 7 +def tC1 : ℚ := 136584 / 10 ^ 7 +def tC2 : ℚ := 137584 / 10 ^ 7 +def tC3 : ℚ := 237584 / 10 ^ 7 +def sgA0 : ℚ := 37981 / 500000 +def sgA1 : ℚ := 77257 / 10 ^ 6 +def sgA2 : ℚ := 213457 / 10 ^ 6 +def sgA3 : ℚ := 560567 / 500000 +def sgC0 : ℚ := 28029 / 500000 +def sgC1 : ℚ := 28683 / 500000 +def sgC2 : ℚ := 200709 / 10 ^ 6 +def sgC3 : ℚ := 1185727 / 10 ^ 6 + + +def lcpA0 : ℚ := 862761 / 50000 +def lcpA1 : ℚ := 17257043 / 10 ^ 6 +def lcpA2 : ℚ := 3469639 / 200000 +def lcpA3 : ℚ := 6597489 / 250000 +def LA0 : ℚ := lcpA0 - 5 * sgA0 +def LA1 : ℚ := lcpA1 - 5 * sgA1 +def LA2 : ℚ := lcpA2 - 5 * sgA2 +def LA3 : ℚ := lcpA3 - 5 * sgA3 +def lcpC0 : ℚ := 12418057 / 10 ^ 6 +def lcpC1 : ℚ := 248359 / 20000 +def lcpC2 : ℚ := 3079357 / 250000 +def lcpC3 : ℚ := 5022921 / 250000 +def LC0 : ℚ := lcpC0 - 5 * sgC0 +def LC1 : ℚ := lcpC1 - 5 * sgC1 +def LC2 : ℚ := lcpC2 - 5 * sgC2 +def LC3 : ℚ := lcpC3 - 5 * sgC3 + +end CongestionI3Dual diff --git a/research/p104-tiered-ceiling/lean/Nov15/CongestionI3DualData.lean b/research/p104-tiered-ceiling/lean/Nov15/CongestionI3DualData.lean new file mode 100644 index 0000000000..ffe636e516 --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/CongestionI3DualData.lean @@ -0,0 +1,12 @@ +import Nov15.CongestionI3DualConst +import Nov15.CongestionI3NumC4 +import Nov15.CongestionI3NumA + +namespace CongestionI3Dual +open NumCertK CongestionI3 + +/-- the tail pieces are covered by the F1 theorems `cfB_neg` / `cfC_neg` -/ +theorem LA3_ge : liftA ≤ 17 * LA3 := by unfold liftA sigma0 LA3 lcpA3 sgA3; norm_num +theorem LC3_ge : liftC ≤ 17 * LC3 := by unfold liftC LcC LC3 lcpC3 sgC3; norm_num + +end CongestionI3Dual diff --git a/research/p104-tiered-ceiling/lean/Nov15/CongestionI3DualNumC.lean b/research/p104-tiered-ceiling/lean/Nov15/CongestionI3DualNumC.lean new file mode 100644 index 0000000000..965d2006a9 --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/CongestionI3DualNumC.lean @@ -0,0 +1,8 @@ +import Nov15.CongestionI3DualConst +import Nov15.CongestionI3NumC4 +namespace CongestionI3Dual +open NumCertK CongestionI3 +theorem ptC0 : Fup cfC (1 - tC0) (1 - tC0) < 17 * LC0 := by unfold tC0 LC0 lcpC0 sgC0; decide +kernel +theorem ptC1 : Fup cfC (1 - tC1) (1 - tC1) < 17 * LC1 := by unfold tC1 LC1 lcpC1 sgC1; decide +kernel +theorem ptC2 : Fup cfC (1 - tC2) (1 - tC2) < 17 * LC2 := by unfold tC2 LC2 lcpC2 sgC2; decide +kernel +end CongestionI3Dual diff --git a/research/p104-tiered-ceiling/lean/Nov15/CongestionI3DualSig.lean b/research/p104-tiered-ceiling/lean/Nov15/CongestionI3DualSig.lean new file mode 100644 index 0000000000..4f46eb66c0 --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/CongestionI3DualSig.lean @@ -0,0 +1,78 @@ +import Nov15.CongestionI3DualAlg +import Nov15.NumCertK +import Nov15.CongestionI3DualConst + +/-! +CONGESTION-I3-DUAL, sigma certificates. `sigma(t)` = the largest c2 of one mixed register (dims 1 <= a <= b <= 8) is CERTIFIED here +on each t-piece by `NumCertK.Fup` (kernel interval arithmetic): for every pair (a,b), min(Fup h9, Fup k0) < sigma on the whole s-interval. So sigma needs +no monotonicity hypothesis: each piece carries its own certified bound. +-/ +namespace CongestionI3Dual +open NumCertK + +def h9CF (a b : ℕ) : CF := [(b - a, 1), (9 - b, 1), (9 - a, -1)] +def k0CF (a b : ℕ) : CF := [(b - a, 1), (a, 1), (b, -1)] + +theorem gs_nat (s : ℝ) (k : ℕ) (hk : 1 ≤ k) : gs s (k : ℝ) = (k : ℝ) ^ s := by + have : (0 : ℝ) < k := by exact_mod_cast hk + simp [gs, this] + +theorem h9_Fc (s : ℝ) (a b : ℕ) (ha : 1 ≤ a) (hab : a < b) (hb : b ≤ 8) : + h9 (gs s) (a : ℝ) (b : ℝ) = Fc (h9CF a b) s := by + have e1 : (b : ℝ) - a = ((b - a : ℕ) : ℝ) := by rw [Nat.cast_sub hab.le] + have e2 : (9 : ℝ) - b = ((9 - b : ℕ) : ℝ) := by rw [Nat.cast_sub (by omega)]; norm_num + have e3 : (9 : ℝ) - a = ((9 - a : ℕ) : ℝ) := by rw [Nat.cast_sub (by omega)]; norm_num + unfold h9; rw [e1, e2, e3, gs_nat s _ (by omega), gs_nat s _ (by omega), gs_nat s _ (by omega)] + simp [Fc, h9CF]; ring + +theorem k0_Fc (s : ℝ) (a b : ℕ) (ha : 1 ≤ a) (hab : a < b) (hb : b ≤ 8) : + k0 (gs s) (a : ℝ) (b : ℝ) = Fc (k0CF a b) s := by + have e1 : (b : ℝ) - a = ((b - a : ℕ) : ℝ) := by rw [Nat.cast_sub hab.le] + unfold k0; rw [e1, gs_nat s _ (by omega), gs_nat s _ ha, gs_nat s _ (by omega)] + simp [Fc, k0CF]; ring + +def pairs : List (ℕ × ℕ) := [(1,2),(1,3),(1,4),(1,5),(1,6),(1,7),(1,8),(2,3),(2,4),(2,5),(2,6),(2,7),(2,8),(3,4),(3,5),(3,6),(3,7),(3,8), + (4,5),(4,6),(4,7),(4,8),(5,6),(5,7),(5,8),(6,7),(6,8),(7,8)] +theorem mem_pairs (a : ℕ) (ha : a < 9) (b : ℕ) (hb : b < 9) (h : 1 ≤ a ∧ a < b ∧ b ≤ 8) : (a, b) ∈ pairs := by + obtain ⟨h1, h2, h3⟩ := h + interval_cases a <;> interval_cases b <;> simp [pairs] at h2 h3 ⊢ + +def sigOK (lo hi σ : ℚ) : Bool := + pairs.all fun p => decide (Fup (h9CF p.1 p.2) lo hi < σ) || decide (Fup (k0CF p.1 p.2) lo hi < σ) + +theorem okR_h9CF (a b : ℕ) (ha : 1 ≤ a) (hab : a < b) (hb : b ≤ 8) : okR (h9CF a b) := by + intro p hp; simp [h9CF] at hp + rcases hp with h | h | h <;> subst h <;> simp <;> omega +theorem okR_k0CF (a b : ℕ) (ha : 1 ≤ a) (hab : a < b) (hb : b ≤ 8) : okR (k0CF a b) := by + intro p hp; simp [k0CF] at hp + rcases hp with h | h | h <;> subst h <;> simp <;> omega + +/-- **sigma certificate**: if `sigOK lo hi σ`, then for every s in [lo, hi], every 1 <= a <= b <= 8: c2 (gs s) a b <= σ (σ >= 0). -/ +theorem sig_of_ok (lo hi σ : ℚ) (hok : sigOK lo hi σ = true) (hlo : 0 ≤ lo) (hhi : hi ≤ 1) (hσ : 0 ≤ σ) (s : ℝ) + (h1 : (lo : ℝ) ≤ s) (h2 : s ≤ (hi : ℝ)) (a b : ℕ) (ha : 1 ≤ a) (hab : a ≤ b) (hb : b ≤ 8) : + c2 (gs s) (a : ℝ) (b : ℝ) ≤ (σ : ℝ) := by + rcases Nat.lt_or_ge a b with h | h + · have hm : (a, b) ∈ pairs := mem_pairs a (by omega) b (by omega) ⟨ha, h, hb⟩ + have := List.all_eq_true.mp hok (a, b) hm + simp only [Bool.or_eq_true, decide_eq_true_eq] at this + unfold c2 + rcases this with hh | hh + · have := Fc_le (h9CF a b) (okR_h9CF a b ha h hb) lo hi hlo hhi s h1 h2 + have h' : ((Fup (h9CF a b) lo hi : ℚ) : ℝ) < σ := by exact_mod_cast hh + rw [← h9_Fc s a b ha h hb] at this + exact le_trans (min_le_left _ _) (by linarith) + · have := Fc_le (k0CF a b) (okR_k0CF a b ha h hb) lo hi hlo hhi s h1 h2 + have h' : ((Fup (k0CF a b) lo hi : ℚ) : ℝ) < σ := by exact_mod_cast hh + rw [← k0_Fc s a b ha h hb] at this + exact le_trans (min_le_right _ _) (by linarith) + · have hba : a = b := le_antisymm hab h + subst hba + have h0 : h9 (gs s) (a : ℝ) (a : ℝ) = 0 := by unfold h9; simp [gs_zero] + have : c2 (gs s) (a : ℝ) (a : ℝ) ≤ 0 := by unfold c2; rw [h0]; exact min_le_left _ _ + have hσ' : (0 : ℝ) ≤ σ := by exact_mod_cast hσ + linarith + +/-! ### the pieces (t in [t_j, t_{j+1}], s in [1 - t_{j+1}, 1 - t_j]) -/ +end CongestionI3Dual + +#print axioms CongestionI3Dual.sig_of_ok diff --git a/research/p104-tiered-ceiling/lean/Nov15/CongestionI3Mu.lean b/research/p104-tiered-ceiling/lean/Nov15/CongestionI3Mu.lean new file mode 100644 index 0000000000..b64a8e7023 --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/CongestionI3Mu.lean @@ -0,0 +1,10 @@ +import Nov15.CongestionI3Data + +/-! +Per-chain flag-DP minima mu[i][k] (config i of `cfgs`, chain k): the minimum, over complete flags < ... < z_k^perp, of the number of +FORCED unique cells of chain k (F1 f1dp.py `flagdp(zp, z, cu)`). DATA from internal notes,b}.log (a rerun of f1dp.py with per-chain +printing; per-config sums reproduce f1dp.log: 1936 each). Python exact DP over the 29k-subspace lattice; NOT kernel-checked. +-/ +namespace CongestionI3 +def muTab : List (List ℕ) := [[242, 242, 242, 242, 242, 242, 242, 242], [242, 242, 242, 242, 242, 242, 242, 242], [242, 242, 242, 242, 242, 242, 242, 242], [242, 242, 242, 242, 242, 242, 242, 242], [242, 242, 242, 242, 242, 242, 242, 242], [242, 242, 242, 242, 242, 242, 242, 242], [242, 242, 242, 242, 242, 242, 242, 242], [242, 242, 242, 242, 242, 242, 242, 242]] +end CongestionI3 diff --git a/research/p104-tiered-ceiling/lean/Nov15/CongestionI3NumA.lean b/research/p104-tiered-ceiling/lean/Nov15/CongestionI3NumA.lean new file mode 100644 index 0000000000..f31be96ce8 --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/CongestionI3NumA.lean @@ -0,0 +1,47 @@ +import Nov15.NumCertK + +/-! +CONGESTION-I3 numeric half A : the 8|9 crossing of F1 (internal notes sec. 3) with NumCertK. +F_base = F of the #7113 caller C(8|9) (caller 6 7) at 17 calls with the native replaced by R1/R2's owned floor (400 * 8^s + 16) and NO stops +(`cfB`; = WholeFloorCover.cfW with the 17 * 88 stop terms (1, -2992), (2, +1496) removed). The I3 lift is the constant 17 * 1936 * sigma0, +sigma0 = 9785438/10^9 <= sp_F(t) (shape-DAG path bound in F currency, F1 f1ceil.spF at t = tbar = .0183952347; DATA, python). +Crossing: dF_base/ds > 0 on [.9, s0] (dLo, kernel), F_base(s0) < 17 * 1936 * sigma0 (kernel), s0 = 1 - tbar, tbar = .0183952347. +-/ +namespace CongestionI3 +open NumCertK + +def cfB : CF := [(1, -656), (8, -7456), (9, 384), (16, -416), (17, 416), (24, -416), (25, 416), (32, -416), (33, 416), + (40, -416), (41, 416), (48, -416), (49, 416), (56, -416), (57, 416), (64, -208), (65, 416), (73, 208), (137, 208)] +def sigma0 : ℚ := 9785438 / 10 ^ 9 +def sA : ℚ := 9816047653 / 10 ^ 10 +def liftA : ℚ := 17 * 1936 * sigma0 + +theorem cfB_ok : okR cfB := by decide +kernel +theorem cfB_p1 : Fup cfB (90 / 100) (91 / 100) < liftA := by decide +kernel +theorem cfB_p2 : Fup cfB (91 / 100) (92 / 100) < liftA := by decide +kernel +theorem cfB_p3 : Fup cfB (92 / 100) (93 / 100) < liftA := by decide +kernel +theorem cfB_d : 0 < dLo cfB (93 / 100) sA := by decide +kernel +theorem cfB_end : Fup cfB sA sA < liftA := by decide +kernel + +/-- F_base(s) < 17 * 1936 * sigma0 on s in [.9, 1 - tbar] -/ +theorem cfB_neg (s : ℝ) (h1 : (9 / 10 : ℝ) ≤ s) (h2 : s ≤ ((sA : ℚ) : ℝ)) : Fc cfB s < ((liftA : ℚ) : ℝ) := by + have piece : ∀ a b : ℚ, 0 ≤ a → b ≤ 1 → Fup cfB a b < liftA → (a : ℝ) ≤ s → s ≤ b → Fc cfB s < ((liftA : ℚ) : ℝ) := by + intro a b ha hb hF h1 h2 + have := Fc_le cfB cfB_ok a b ha hb s h1 h2 + have h' : ((Fup cfB a b : ℚ) : ℝ) < ((liftA : ℚ) : ℝ) := by exact_mod_cast hF + linarith + by_cases c1 : s ≤ (((91 / 100 : ℚ)) : ℝ) + · exact piece (90 / 100) (91 / 100) (by norm_num) (by norm_num) cfB_p1 (by push_cast; linarith) c1 + by_cases c2 : s ≤ (((92 / 100 : ℚ)) : ℝ) + · exact piece (91 / 100) (92 / 100) (by norm_num) (by norm_num) cfB_p2 (by push_neg at c1; exact c1.le) c2 + by_cases hc : s ≤ (((93 / 100 : ℚ)) : ℝ) + · exact piece (92 / 100) (93 / 100) (by norm_num) (by norm_num) cfB_p3 (by push_neg at c2; exact c2.le) hc + have h1' : (((93 / 100 : ℚ)) : ℝ) ≤ s := by push_neg at hc; exact hc.le + have hm := Fc_mono cfB cfB_ok (93 / 100) sA (by norm_num) (by unfold sA; norm_num) cfB_d s h1' h2 + have he := Fc_le cfB cfB_ok sA sA (by unfold sA; norm_num) (by unfold sA; norm_num) sA (le_refl _) (le_refl _) + have he' : ((Fup cfB sA sA : ℚ) : ℝ) < ((liftA : ℚ) : ℝ) := by exact_mod_cast cfB_end + linarith + +end CongestionI3 + +#print axioms CongestionI3.cfB_neg diff --git a/research/p104-tiered-ceiling/lean/Nov15/CongestionI3NumC1.lean b/research/p104-tiered-ceiling/lean/Nov15/CongestionI3NumC1.lean new file mode 100644 index 0000000000..2533bd0108 --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/CongestionI3NumC1.lean @@ -0,0 +1,23 @@ +import Nov15.NumCertK + +/-! +CONGESTION-I3 numeric half C1 : own56 ceiling data, part 1. With the decoder's descent mass >= 56 charged (LIFT1 sec. 3: +cheapest F form 6 * 9^s + 2 * 1 plus 8 rises), the 17-call base is F_base = F(caller 6 7) - 17 (400 * 8^s + 6 * 9^s + 10) (`cfC`). `cfC88` +adds R3's 88 forced stops (-17 * 88 * (2 - 2^s): (1, -2992), (2, +1496)); F < 0 on s in [0, .9] (t >= .1) is covered here and in C2. +-/ +namespace CongestionI3 +open NumCertK + +def cfC : CF := [(1, -554), (8, -7456), (9, 282), (16, -416), (17, 416), (24, -416), (25, 416), (32, -416), (33, 416), + (40, -416), (41, 416), (48, -416), (49, 416), (56, -416), (57, 416), (64, -208), (65, 416), (73, 208), (137, 208)] +def cfC88 : CF := [(1, -3546), (2, 1496), (8, -7456), (9, 282), (16, -416), (17, 416), (24, -416), (25, 416), (32, -416), (33, 416), + (40, -416), (41, 416), (48, -416), (49, 416), (56, -416), (57, 416), (64, -208), (65, 416), (73, 208), (137, 208)] +theorem cfC_ok : okR cfC := by decide +kernel +theorem cfC88_ok : okR cfC88 := by decide +kernel +theorem cfC88_p1 : Fup cfC88 (0) (22/100) < 0 := by decide +kernel +theorem cfC88_p2 : Fup cfC88 (22/100) (39/100) < 0 := by decide +kernel +theorem cfC88_p3 : Fup cfC88 (39/100) (51/100) < 0 := by decide +kernel +theorem cfC88_p4 : Fup cfC88 (51/100) (6/10) < 0 := by decide +kernel +theorem cfC88_p5 : Fup cfC88 (6/10) (67/100) < 0 := by decide +kernel + +end CongestionI3 diff --git a/research/p104-tiered-ceiling/lean/Nov15/CongestionI3NumC2.lean b/research/p104-tiered-ceiling/lean/Nov15/CongestionI3NumC2.lean new file mode 100644 index 0000000000..00254cf788 --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/CongestionI3NumC2.lean @@ -0,0 +1,13 @@ +import Nov15.CongestionI3NumC1 + +/-! CONGESTION-I3 numeric part C2 : kernel interval pieces for the own56 ceiling; see CongestionI3NumC1 and CongestionI3.md. -/ +namespace CongestionI3 +open NumCertK + +theorem cfC88_p6 : Fup cfC88 (67/100) (72/100) < 0 := by decide +kernel +theorem cfC88_p7 : Fup cfC88 (72/100) (76/100) < 0 := by decide +kernel +theorem cfC88_p8 : Fup cfC88 (76/100) (79/100) < 0 := by decide +kernel +theorem cfC88_p9 : Fup cfC88 (79/100) (81/100) < 0 := by decide +kernel +theorem cfC88_p10 : Fup cfC88 (81/100) (83/100) < 0 := by decide +kernel + +end CongestionI3 diff --git a/research/p104-tiered-ceiling/lean/Nov15/CongestionI3NumC3.lean b/research/p104-tiered-ceiling/lean/Nov15/CongestionI3NumC3.lean new file mode 100644 index 0000000000..ddb23f0913 --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/CongestionI3NumC3.lean @@ -0,0 +1,17 @@ +import Nov15.CongestionI3NumC2 + +/-! CONGESTION-I3 numeric part C3 : kernel interval pieces for the own56 ceiling; see CongestionI3NumC1 and CongestionI3.md. -/ +namespace CongestionI3 +open NumCertK + +def sC : ℚ := 1 - 134769139 / 10 ^ 10 +def LcC : ℚ := 1364105 / 10 ^ 5 +def liftC : ℚ := 17 * LcC + +theorem cfC88_p11 : Fup cfC88 (83/100) (86/100) < 0 := by decide +kernel +theorem cfC88_p12 : Fup cfC88 (86/100) (88/100) < 0 := by decide +kernel +theorem cfC88_p13 : Fup cfC88 (88/100) (9/10) < 0 := by decide +kernel +theorem cfC_q1 : Fup cfC (90 / 100) (915 / 1000) < liftC := by decide +kernel +theorem cfC_q2 : Fup cfC (915 / 1000) (93 / 100) < liftC := by decide +kernel + +end CongestionI3 diff --git a/research/p104-tiered-ceiling/lean/Nov15/CongestionI3NumC4.lean b/research/p104-tiered-ceiling/lean/Nov15/CongestionI3NumC4.lean new file mode 100644 index 0000000000..b6b5c40c1d --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/CongestionI3NumC4.lean @@ -0,0 +1,59 @@ +import Nov15.CongestionI3NumC3 + +/-! CONGESTION-I3 numeric part C4 : kernel interval pieces for the own56 ceiling; see CongestionI3NumC1 and CongestionI3.md. -/ +namespace CongestionI3 +open NumCertK + +theorem cfC_d : 0 < dLo cfC (93 / 100) sC := by decide +kernel +theorem cfC_end : Fup cfC sC sC < liftC := by decide +kernel + +theorem cfC88_neg (s : ℝ) (h0 : 0 ≤ s) (hs : s ≤ (9 / 10 : ℝ)) : Fc cfC88 s < 0 := by + have piece : ∀ a b : ℚ, 0 ≤ a → b ≤ 1 → Fup cfC88 a b < 0 → (a : ℝ) ≤ s → s ≤ b → Fc cfC88 s < 0 := + fun a b ha hb hF h1 h2 => Fc_neg_piece cfC88 cfC88_ok a b ha hb hF s h1 h2 + by_cases c1 : s ≤ (((22/100) : ℚ) : ℝ) + · exact piece (0) (22/100) (by norm_num) (by norm_num) cfC88_p1 (by simpa using h0) c1 + by_cases c2 : s ≤ (((39/100) : ℚ) : ℝ) + · exact piece (22/100) (39/100) (by norm_num) (by norm_num) cfC88_p2 (by push_cast; push_neg at c1; linarith) c2 + by_cases c3 : s ≤ (((51/100) : ℚ) : ℝ) + · exact piece (39/100) (51/100) (by norm_num) (by norm_num) cfC88_p3 (by push_cast; push_neg at c2; linarith) c3 + by_cases c4 : s ≤ (((6/10) : ℚ) : ℝ) + · exact piece (51/100) (6/10) (by norm_num) (by norm_num) cfC88_p4 (by push_cast; push_neg at c3; linarith) c4 + by_cases c5 : s ≤ (((67/100) : ℚ) : ℝ) + · exact piece (6/10) (67/100) (by norm_num) (by norm_num) cfC88_p5 (by push_cast; push_neg at c4; linarith) c5 + by_cases c6 : s ≤ (((72/100) : ℚ) : ℝ) + · exact piece (67/100) (72/100) (by norm_num) (by norm_num) cfC88_p6 (by push_cast; push_neg at c5; linarith) c6 + by_cases c7 : s ≤ (((76/100) : ℚ) : ℝ) + · exact piece (72/100) (76/100) (by norm_num) (by norm_num) cfC88_p7 (by push_cast; push_neg at c6; linarith) c7 + by_cases c8 : s ≤ (((79/100) : ℚ) : ℝ) + · exact piece (76/100) (79/100) (by norm_num) (by norm_num) cfC88_p8 (by push_cast; push_neg at c7; linarith) c8 + by_cases c9 : s ≤ (((81/100) : ℚ) : ℝ) + · exact piece (79/100) (81/100) (by norm_num) (by norm_num) cfC88_p9 (by push_cast; push_neg at c8; linarith) c9 + by_cases c10 : s ≤ (((83/100) : ℚ) : ℝ) + · exact piece (81/100) (83/100) (by norm_num) (by norm_num) cfC88_p10 (by push_cast; push_neg at c9; linarith) c10 + by_cases c11 : s ≤ (((86/100) : ℚ) : ℝ) + · exact piece (83/100) (86/100) (by norm_num) (by norm_num) cfC88_p11 (by push_cast; push_neg at c10; linarith) c11 + by_cases c12 : s ≤ (((88/100) : ℚ) : ℝ) + · exact piece (86/100) (88/100) (by norm_num) (by norm_num) cfC88_p12 (by push_cast; push_neg at c11; linarith) c12 + exact piece (88/100) (9/10) (by norm_num) (by norm_num) cfC88_p13 (by push_cast; push_neg at c12; linarith) (by push_cast; linarith) + +/-- F_base < 17 * LcC on s in [.9, 1 - tbarC] (the lift is the constant 17 * LcC) -/ +theorem cfC_neg (s : ℝ) (h1 : (9 / 10 : ℝ) ≤ s) (h2 : s ≤ ((sC : ℚ) : ℝ)) : Fc cfC s < ((liftC : ℚ) : ℝ) := by + have piece : ∀ a b : ℚ, 0 ≤ a → b ≤ 1 → Fup cfC a b < liftC → (a : ℝ) ≤ s → s ≤ b → Fc cfC s < ((liftC : ℚ) : ℝ) := by + intro a b ha hb hF h1 h2 + have := Fc_le cfC cfC_ok a b ha hb s h1 h2 + have h' : ((Fup cfC a b : ℚ) : ℝ) < ((liftC : ℚ) : ℝ) := by exact_mod_cast hF + linarith + by_cases c1 : s ≤ (((915 / 1000 : ℚ)) : ℝ) + · exact piece (90 / 100) (915 / 1000) (by norm_num) (by norm_num) cfC_q1 (by push_cast; linarith) c1 + by_cases c2 : s ≤ (((93 / 100 : ℚ)) : ℝ) + · exact piece (915 / 1000) (93 / 100) (by norm_num) (by norm_num) cfC_q2 (by push_neg at c1; exact c1.le) c2 + have h1' : (((93 / 100 : ℚ)) : ℝ) ≤ s := by push_neg at c2; exact c2.le + have hm := Fc_mono cfC cfC_ok (93 / 100) sC (by norm_num) (by unfold sC; norm_num) cfC_d s h1' h2 + have he := Fc_le cfC cfC_ok sC sC (by unfold sC; norm_num) (by unfold sC; norm_num) sC (le_refl _) (le_refl _) + have he' : ((Fup cfC sC sC : ℚ) : ℝ) < ((liftC : ℚ) : ℝ) := by exact_mod_cast cfC_end + linarith + +end CongestionI3 + +#print axioms CongestionI3.cfC88_neg +#print axioms CongestionI3.cfC_neg diff --git a/research/p104-tiered-ceiling/lean/Nov15/CongestionNative.lean b/research/p104-tiered-ceiling/lean/Nov15/CongestionNative.lean new file mode 100644 index 0000000000..899afcb54b --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/CongestionNative.lean @@ -0,0 +1,319 @@ +import Nov15.CongestionI3 +import Nov15.CongestionI3DualAlg +import Nov15.CongestionI3DualSig +import Nov15.CongestionI3DualConst +import Nov15.CongestionI3DualData +import Nov15.CongestionI3DualNumC +import Nov15.CongestionI3DualCertC0 +import Nov15.CongestionI3DualCertC1 +import Nov15.CongestionI3DualCertC2 +import Nov15.CongestionI3DualCertC3 +import Nov15.CongestionNativeTab + +/-! +CONGESTION-NATIVE: the native-covering ceiling kappa <= .0136564 (own56, 8|9, m <= 5), the corrected form of +`CongestionI3Dual.ceiling_C2` (a COPY; the shipped files are unchanged). See CongestionNative.md for the hypothesis ledger. +Changes against ceiling_C2 (HC1-HC4, AUD, AUD2 FIX A-C): +* hcong* carries the owned surplus `Omega = dprice ks s + mr - (6 * 9^s + 10)` on the right (ks = descents + non-unit rises, mr = unit rises: FIX-1) and is + stated only for s in [.9, 1 - tC0]; `hE` is generalised to `Lj <= E + Omega` (`branchC_om`, `E_lower_cap_om`). +* ONE J throughout (J = J^arr, the arrival residual): hcong*, hdist and hJ all use the same variable `J`. +* The placeholder Props (Rank8C56, Prov) are gone; `ell`, `corr`, `cap` are concrete (`ellC`, `corrC`, `capC`); `LcTabC` is DERIVED from + rational tables (CongestionNativeTab) and the hypotheses hspMono/hcstMono/hspTab/hcstTab/hunitTab. +* `hcong_of_capclass` (+ PathCut.lean) formalises the accounting that proves hcong* from the Cap class. +-/ +namespace CongestionNative +open NumCertK JointCeiling CallerCost CongestionI3 CongestionI3Dual Finset + +/-! ### 0. copied from CongestionI3Dual (F_base monotonicity and point enclosures, own56 side) -/ +theorem Fc_monoOn (cf : CF) (hok : okR cf) (a b : ℚ) (ha : 0 ≤ a) (hb1 : b ≤ 1) (hd : 0 < dLo cf a b) + (s s' : ℝ) (h1 : (a : ℝ) ≤ s) (hss : s ≤ s') (h2 : s' ≤ (b : ℝ)) : Fc cf s ≤ Fc cf s' := by + have hab : (a : ℝ) ≤ b := le_trans h1 (le_trans hss h2) + have hcont : ContinuousOn (Fc cf) (Set.Icc (a : ℝ) b) := + fun x _ => (Fc_hasDerivAt cf hok x).continuousAt.continuousWithinAt + have hm : StrictMonoOn (Fc cf) (Set.Icc (a : ℝ) b) := by + apply strictMonoOn_of_deriv_pos (convex_Icc _ _) hcont + intro x hx + rw [interior_Icc] at hx + rw [(Fc_hasDerivAt cf hok x).deriv] + have := dFc_ge cf hok a b ha hb1 x hx.1.le hx.2.le + have hd' : (0:ℝ) < ((dLo cf a b : ℚ) : ℝ) := by exact_mod_cast hd + linarith + exact hm.monotoneOn ⟨h1, le_trans hss h2⟩ ⟨le_trans h1 hss, h2⟩ hss + +theorem cfC_monoOn (s s' : ℝ) (h1 : (93 / 100 : ℝ) ≤ s) (hss : s ≤ s') (h2 : s' ≤ ((sC : ℚ) : ℝ)) : Fc cfC s ≤ Fc cfC s' := + Fc_monoOn cfC cfC_ok (93 / 100) sC (by norm_num) (by unfold sC; norm_num) cfC_d s s' + (by rw [show (((93 / 100 : ℚ)) : ℝ) = 93 / 100 by norm_num]; exact h1) hss h2 + +theorem pt_of_Fup (cf : CF) (hok : okR cf) (q L : ℚ) (hq0 : 0 ≤ q) (hq1 : q ≤ 1) (h : Fup cf q q < 17 * L) : + Fc cf (q : ℝ) < 17 * (L : ℝ) := by + have h1 := Fc_le cf hok q q hq0 hq1 (q : ℝ) (le_refl _) (le_refl _) + have h2 : ((Fup cf q q : ℚ) : ℝ) < ((17 * L : ℚ) : ℝ) := by exact_mod_cast h + push_cast at h2 + linarith + +theorem hFbC_of (a b L : ℚ) (hb93 : 93 / 100 ≤ 1 - b) (hab : a ≤ b) (haA : 1 - a ≤ sC) (ha0 : 0 ≤ a) + (hpt : Fup cfC (1 - a) (1 - a) < 17 * L) : + ∀ s : ℝ, ((1 - b : ℚ) : ℝ) ≤ s → s ≤ ((1 - a : ℚ) : ℝ) → Fc cfC s < 17 * (L : ℝ) := by + intro s h1 h2 + have hb : (((93 / 100 : ℚ)) : ℝ) ≤ s := le_trans (by exact_mod_cast hb93) h1 + have hb' : (93 / 100 : ℝ) ≤ s := by rwa [show (((93 / 100 : ℚ)) : ℝ) = 93 / 100 by norm_num] at hb + have hm := cfC_monoOn s ((1 - a : ℚ) : ℝ) hb' h2 (by exact_mod_cast haA) + exact lt_of_le_of_lt hm (pt_of_Fup cfC cfC_ok (1 - a) L (by linarith [(by exact_mod_cast hab : (a : ℚ) ≤ b)]) (by linarith) hpt) + +/-! ### 1. concrete definitions -/ + +/-- owned surplus: all owned moves `|k|^s` (ks = descents + non-unit rises, mr = unit rises, price 1 each) minus what `own56_floor` charges (6 * 9^s + 10). -/ +noncomputable def Omega (ks : List ℕ) (mr : ℕ) (s : ℝ) : ℝ := dprice ks s + mr - (6 * (9 : ℝ) ^ s + 10) +/-- per-cell cap `(9^s - 8^s) / 48` -/ +noncomputable def capC (s : ℝ) : ℝ := ((9 : ℝ) ^ s - (8 : ℝ) ^ s) / 48 +/-- lower bound of the capped per-cell distance: `min (spF (1 - s)) (cap s)` -/ +noncomputable def ellC (spF : ℝ → ℝ) (s : ℝ) : ℝ := min (spF (1 - s)) (capC s) +/-- LIFT1 rise correction `8 * cst(1 - s)` -/ +noncomputable def corrC (cstF : ℝ → ℝ) (s : ℝ) : ℝ := 8 * cstF (1 - s) + +/-! ### 2. two-sided I3 with the owned surplus on the right -/ +section Elower +variable {ι : Type*} [DecidableEq ι] + +/-- two-sided I3, cap/correction form with surplus: `sum min (dist, cap) - corr <= charges + Om` gives `E + Om >= 1936 ell - corr - m sigma`. -/ +theorem E_lower_cap_om (R : Finset ι) (n : ι → ℕ) (d : ι → ℕ → ℕ) (J : Finset (ℕ × ℕ)) (dist : ℕ × ℕ → ℝ) + (E s cap corr ell σ Om : ℝ) (m : ℕ) + (hmono : ∀ r ∈ R, ∀ i < n r, d r i ≤ d r (i + 1)) (hd9 : ∀ r ∈ R, d r (n r) ≤ 9) + (hm : (R.filter fun r => Mixed d n r).card ≤ m) (hσ0 : 0 ≤ σ) + (hσ : ∀ a b : ℕ, 1 ≤ a → a ≤ b → b ≤ 8 → c2 (gs s) (a : ℝ) (b : ℝ) ≤ σ) + (hcong : ∑ p ∈ J, min (dist p) cap - corr ≤ ∑ r ∈ R, ∑ i ∈ range (n r), c2 (gs s) (lev d r i) (lev d r (i + 1)) + Om) + (hEex : ∑ r ∈ R, ex (gs s) (lev d r) (n r) ≤ E) (hdist : ∀ p ∈ J, ell ≤ min (dist p) cap) (hJ : 1936 ≤ J.card) (hell : 0 ≤ ell) : + 1936 * ell - corr - m * σ ≤ E + Om := by + have h1 := sum_all_c2_le (gs s) (gs_zero s) R n d hmono hd9 m hm σ hσ0 hσ + have h2 := Finset.card_nsmul_le_sum J (fun p => min (dist p) cap) ell hdist + rw [nsmul_eq_mul] at h2 + have hj : (1936 : ℝ) ≤ J.card := by exact_mod_cast hJ + nlinarith + +end Elower + +/-! ### 3. the branch with the surplus (the 88c branch is only needed for t >= .1) -/ + +theorem branchC_om (n : Inv) (ks : List ℕ) (mr : ℕ) (E Lj s : ℝ) + (hF : Finv s n ≤ -400 * (8 : ℝ) ^ s - dprice ks s - mr - E) + (hE : Lj ≤ E + Omega ks mr s) (hFb : Fc cfC s < 17 * Lj) : + Finv s (invoice (caller 6 7) n 17) < 0 := by + have h1' : Finv s n ≤ -400 * (8 : ℝ) ^ s - (6 * (9 : ℝ) ^ s + 10) - Lj := by + unfold Omega at hE; linarith + have h2 := invoice_F s (caller 6 7) n 17 + have h3 := invoice_F s (caller 6 7) natBaseC 17 + have h4 := natBaseC_F s + have h6 := baseC_eq s + push_cast at h2 h3 + nlinarith + +/-! ### 4. the Cap-class accounting (HC1 sec. 2): hcong* from legal + transported cells -/ + +/-- `J` splits into LEGAL cells (a descent-free D_t-confined path: I3 charge + rise saving `cst * Rm`) and TRANSPORTED cells (cut at an owned descent, `<= 48 * Nf` of them, each at most `cap = U/48`). +Then `sum min - 8 cst <= Pub + Om` as soon as the Cap class inequality `cst (Rm - 8) + U Nf <= Om` holds. -/ +theorem hcong_of_capclass (J : Finset (ℕ × ℕ)) (leg : ℕ × ℕ → Prop) [DecidablePred leg] (dist : ℕ × ℕ → ℝ) + (cap U Pub cst Rm Nf Om : ℝ) (hcap : cap = U / 48) (hU : 0 ≤ U) + (hleg : ∑ p ∈ J.filter leg, dist p ≤ Pub + cst * Rm) + (hT : ((J.filter fun p => ¬ leg p).card : ℝ) ≤ 48 * Nf) + (hclass : cst * (Rm - 8) + U * Nf ≤ Om) : + ∑ p ∈ J, min (dist p) cap - 8 * cst ≤ Pub + Om := by + have hsplit := Finset.sum_filter_add_sum_filter_not J leg (fun p => min (dist p) cap) + have h1 : ∑ p ∈ J.filter leg, min (dist p) cap ≤ ∑ p ∈ J.filter leg, dist p := + Finset.sum_le_sum fun p _ => min_le_left _ _ + have h2 : ∑ p ∈ J.filter (fun p => ¬ leg p), min (dist p) cap ≤ ∑ _p ∈ J.filter (fun p => ¬ leg p), cap := + Finset.sum_le_sum fun p _ => min_le_right _ _ + rw [Finset.sum_const, nsmul_eq_mul] at h2 + have hc0 : 0 ≤ cap := by rw [hcap]; positivity + have h3 : ((J.filter fun p => ¬ leg p).card : ℝ) * cap ≤ 48 * Nf * cap := mul_le_mul_of_nonneg_right hT hc0 + have h4 : 48 * Nf * cap = U * Nf := by rw [hcap]; ring + nlinarith + +/-! ### 5. the derived table `LcTabC` -/ + +theorem unit_mono (s s' : ℝ) (hs : 0 ≤ s) (h : s ≤ s') : (9 : ℝ) ^ s - (8 : ℝ) ^ s ≤ (9 : ℝ) ^ s' - (8 : ℝ) ^ s' := by + have e : ∀ x : ℝ, (9 : ℝ) ^ x - (8 : ℝ) ^ x = (8 : ℝ) ^ x * (((9 : ℝ) / 8) ^ x - 1) := by + intro x + have h9 : (9 : ℝ) ^ x = (8 : ℝ) ^ x * ((9 : ℝ) / 8) ^ x := by + rw [← Real.mul_rpow (by norm_num) (by norm_num)]; norm_num + rw [h9]; ring + rw [e, e] + have h1 : (8 : ℝ) ^ s ≤ (8 : ℝ) ^ s' := Real.rpow_le_rpow_of_exponent_le (by norm_num) h + have h2 : ((9 : ℝ) / 8) ^ s ≤ ((9 : ℝ) / 8) ^ s' := Real.rpow_le_rpow_of_exponent_le (by norm_num) h + have h3 : (1 : ℝ) ≤ ((9 : ℝ) / 8) ^ s := Real.one_le_rpow (by norm_num) hs + exact mul_le_mul h1 (by linarith) (by linarith) (by positivity) + +/-- one t-piece `[a, b]` of the own56 table: `lcp <= 1936 ell - corr` follows from the rational table and endpoint hypotheses (monotonicity of spF and cst in t). -/ +theorem tab_piece (spF cstF : ℝ → ℝ) (a b : ℚ) (lcp cH spLo unLo : ℚ) (hlcp : 0 ≤ lcp) (hcH : 0 ≤ cH) (ha0 : tC0 ≤ a) (hab : a ≤ b) (hb : b ≤ 1 / 10) + (hmS : MonotoneOn spF (Set.Icc ((tC0 : ℚ) : ℝ) (1 / 10))) (hmC : MonotoneOn cstF (Set.Icc ((tC0 : ℚ) : ℝ) (1 / 10))) + (hsp : (spLo : ℝ) ≤ spF (a : ℝ)) (hcs : cstF (b : ℝ) ≤ cH) + (hun : (unLo : ℝ) ≤ (9 : ℝ) ^ (1 - (b : ℝ)) - (8 : ℝ) ^ (1 - (b : ℝ))) + (hn1 : lcp + 8 * cH ≤ 1936 * spLo) (hn2 : lcp + 8 * cH ≤ 1936 * (unLo / 48)) : + ∀ s : ℝ, ((1 - b : ℚ) : ℝ) ≤ s → s ≤ ((1 - a : ℚ) : ℝ) → (lcp : ℝ) ≤ 1936 * ellC spF s - corrC cstF s ∧ 0 ≤ ellC spF s := by + intro s h1 h2 + push_cast at h1 h2 + have ha' : ((tC0 : ℚ) : ℝ) ≤ a := by exact_mod_cast ha0 + have hab' : (a : ℝ) ≤ b := by exact_mod_cast hab + have hb' : (b : ℝ) ≤ 1 / 10 := by + have := (Rat.cast_le (K := ℝ)).mpr hb + push_cast at this; exact this + have htl : (a : ℝ) ≤ 1 - s := by linarith + have htu : 1 - s ≤ (b : ℝ) := by linarith + have hspt : spF a ≤ spF (1 - s) := hmS ⟨ha', by linarith⟩ ⟨by linarith, by linarith⟩ htl + have hcst : cstF (1 - s) ≤ cstF b := hmC ⟨by linarith, by linarith⟩ ⟨by linarith, hb'⟩ htu + have hcap : (unLo : ℝ) / 48 ≤ capC s := by + have := unit_mono (1 - b) s (by linarith) h1 + unfold capC; linarith + have hell : min (spLo : ℝ) ((unLo : ℝ) / 48) ≤ ellC spF s := by + unfold ellC + exact le_min (le_trans (min_le_left _ _) (by linarith)) (le_trans (min_le_right _ _) hcap) + have hcorr : corrC cstF s ≤ 8 * (cH : ℝ) := by unfold corrC; linarith + have hn1' : (lcp : ℝ) + 8 * cH ≤ 1936 * spLo := by exact_mod_cast hn1 + have hn2' : (lcp : ℝ) + 8 * cH ≤ 1936 * ((unLo : ℝ) / 48) := by exact_mod_cast hn2 + have hl0 : (0 : ℝ) ≤ lcp := by exact_mod_cast hlcp + have hc0 : (0 : ℝ) ≤ cH := by exact_mod_cast hcH + rcases le_total (spLo : ℝ) ((unLo : ℝ) / 48) with hh | hh + · rw [min_eq_left hh] at hell; exact ⟨by linarith, by linarith⟩ + · rw [min_eq_right hh] at hell; exact ⟨by linarith, by linarith⟩ + +/-! ### 6. the native-covering ceiling -/ + +/-- **native-covering ceiling.** For a word whose public registers have at most 5 mixed registers (`hmix`) and whose owned layer splits as `ks` (descents + non-unit rises) and `mr` (unit rises), +if the congestion step `hcong` (with the owned surplus), the distance floor `hdist`, `hJ` (|J| >= 1936) hold for ONE set `J` (= J^arr), together with the accounting identities and the +certified tables, then `F(1 - t, invoice (caller 6 7) n 17) < 0` for all t in [tC0, 1], i.e. kappa <= tC0 = .0136564 (8|9). Every hypothesis is listed in CongestionNative.md. -/ +theorem ceiling_native {ι : Type*} [DecidableEq ι] + (R : Finset ι) (nR : ι → ℕ) (dR : ι → ℕ → ℕ) + (hmono : ∀ r ∈ R, ∀ i < nR r, dR r i ≤ dR r (i + 1)) (hd9 : ∀ r ∈ R, dR r (nR r) ≤ 9) + (hmix : (R.filter fun r => Mixed dR nR r).card ≤ 5) + (n : Inv) (ks : List ℕ) (mr st : ℕ) (E : ℝ → ℝ) (J : Finset (ℕ × ℕ)) (distF : ℝ → ℕ × ℕ → ℝ) (spF cstF : ℝ → ℝ) + (hk : ∀ k ∈ ks, 1 ≤ k ∧ k ≤ 9) (hmass : 56 ≤ ks.sum) (hmd : 8 ≤ ks.length) (hmr : 8 ≤ mr) + (hF : ∀ s, 0 ≤ s → s ≤ 1 → Finv s n ≤ -400 * (8 : ℝ) ^ s - dprice ks s - mr - E s) + (hY : 104 ≤ st + (ks.length + mr)) + (hst : ∀ s, 0 ≤ s → s ≤ 1 → (2 - (2 : ℝ) ^ s) * st ≤ E s) + (hEex : ∀ s, 0 ≤ s → s ≤ 1 → ∑ r ∈ R, ex (gs s) (lev dR r) (nR r) ≤ E s) + (hcong : ∀ s, 9 / 10 ≤ s → s ≤ 1 - ((tC0 : ℚ) : ℝ) → + ∑ p ∈ J, min (distF s p) (capC s) - corrC cstF s ≤ + ∑ r ∈ R, ∑ i ∈ range (nR r), c2 (gs s) (lev dR r i) (lev dR r (i + 1)) + Omega ks mr s) + (hdist : ∀ s, 9 / 10 ≤ s → s ≤ 1 - ((tC0 : ℚ) : ℝ) → ∀ p ∈ J, spF (1 - s) ≤ distF s p) + (hJ : 1936 ≤ J.card) + (hspMono : MonotoneOn spF (Set.Icc ((tC0 : ℚ) : ℝ) (1 / 10))) + (hcstMono : MonotoneOn cstF (Set.Icc ((tC0 : ℚ) : ℝ) (1 / 10))) + (hspTab : ((spFloC0 : ℚ) : ℝ) ≤ spF ((tC0 : ℚ) : ℝ) ∧ ((spFloC1 : ℚ) : ℝ) ≤ spF ((tC1 : ℚ) : ℝ) ∧ + ((spFloC2 : ℚ) : ℝ) ≤ spF ((tC2 : ℚ) : ℝ) ∧ ((spFloC3 : ℚ) : ℝ) ≤ spF ((tC3 : ℚ) : ℝ)) + (hcstTab : cstF ((tC1 : ℚ) : ℝ) ≤ ((cHC0 : ℚ) : ℝ) ∧ cstF ((tC2 : ℚ) : ℝ) ≤ ((cHC1 : ℚ) : ℝ) ∧ + cstF ((tC3 : ℚ) : ℝ) ≤ ((cHC2 : ℚ) : ℝ) ∧ cstF (1 / 10) ≤ ((cHC3 : ℚ) : ℝ)) + (hunitTab : ((unitLoC0 : ℚ) : ℝ) ≤ (9 : ℝ) ^ (1 - ((tC1 : ℚ) : ℝ)) - (8 : ℝ) ^ (1 - ((tC1 : ℚ) : ℝ)) ∧ + ((unitLoC1 : ℚ) : ℝ) ≤ (9 : ℝ) ^ (1 - ((tC2 : ℚ) : ℝ)) - (8 : ℝ) ^ (1 - ((tC2 : ℚ) : ℝ)) ∧ + ((unitLoC2 : ℚ) : ℝ) ≤ (9 : ℝ) ^ (1 - ((tC3 : ℚ) : ℝ)) - (8 : ℝ) ^ (1 - ((tC3 : ℚ) : ℝ)) ∧ + ((unitLoC3 : ℚ) : ℝ) ≤ (9 : ℝ) ^ (1 - (1 / 10 : ℝ)) - (8 : ℝ) ^ (1 - (1 / 10 : ℝ))) : + ∀ t : ℝ, ((tC0 : ℚ) : ℝ) ≤ t → t ≤ 1 → Finv (1 - t) (invoice (caller 6 7) n 17) < 0 := by + have piece : ∀ (a b lcp σ : ℚ), sigOK (1 - b) (1 - a) σ = true → 0 ≤ σ → tC0 ≤ a → a ≤ b → b ≤ 1 / 10 → 0 ≤ lcp → + (∀ s : ℝ, ((1 - b : ℚ) : ℝ) ≤ s → s ≤ ((1 - a : ℚ) : ℝ) → (lcp : ℝ) ≤ 1936 * ellC spF s - corrC cstF s ∧ 0 ≤ ellC spF s) → + (∀ s : ℝ, ((1 - b : ℚ) : ℝ) ≤ s → s ≤ ((1 - a : ℚ) : ℝ) → Fc cfC s < 17 * (((lcp - 5 * σ : ℚ)) : ℝ)) → + ∀ t : ℝ, (a : ℝ) ≤ t → t ≤ (b : ℝ) → Finv (1 - t) (invoice (caller 6 7) n 17) < 0 := by + intro a b lcp σ hσc hσ0 ha0 hab hb hl0 hLcp hFb t h1 h2 + have ha0q : (0 : ℚ) ≤ a := le_trans (by unfold tC0; norm_num) ha0 + have ha0' : ((tC0 : ℚ) : ℝ) ≤ a := by exact_mod_cast ha0 + have hb' : (b : ℝ) ≤ 1 / 10 := by + have := (Rat.cast_le (K := ℝ)).mpr hb + push_cast at this; exact this + have hab' : (a : ℝ) ≤ b := by exact_mod_cast hab + have hA0 : (0 : ℝ) ≤ a := by exact_mod_cast ha0q + have hs0 : 0 ≤ 1 - t := by linarith + have hs1 : 1 - t ≤ 1 := by linarith + have hσ : ∀ a' b' : ℕ, 1 ≤ a' → a' ≤ b' → b' ≤ 8 → c2 (gs (1 - t)) (a' : ℝ) (b' : ℝ) ≤ (σ : ℝ) := by + intro a' b' h1' h2' h3' + exact sig_of_ok (1 - b) (1 - a) σ hσc (by linarith) (by linarith) hσ0 (1 - t) + (by push_cast; linarith) (by push_cast; linarith) a' b' h1' h2' h3' + have hl0' : (0 : ℝ) ≤ lcp := by exact_mod_cast hl0 + have hLcp' := hLcp (1 - t) (by push_cast; linarith) (by push_cast; linarith) + have hslo : (9 / 10 : ℝ) ≤ 1 - t := by linarith + have hshi : 1 - t ≤ 1 - ((tC0 : ℚ) : ℝ) := by linarith + have hell : 0 ≤ ellC spF (1 - t) := hLcp'.2 + have hE := E_lower_cap_om R nR dR J (distF (1 - t)) (E (1 - t)) (1 - t) (capC (1 - t)) (corrC cstF (1 - t)) (ellC spF (1 - t)) + (σ : ℝ) (Omega ks mr (1 - t)) 5 hmono hd9 hmix (by exact_mod_cast hσ0) hσ (hcong (1 - t) hslo hshi) (hEex _ hs0 hs1) + (fun p hp => le_min (le_trans (min_le_left _ _) (hdist (1 - t) hslo hshi p hp)) (min_le_right _ _)) hJ hell + have hE' : (((lcp - 5 * σ : ℚ)) : ℝ) ≤ E (1 - t) + Omega ks mr (1 - t) := by push_cast; push_cast at hE; linarith [hLcp'.1] + exact branchC_om n ks mr (E (1 - t)) _ (1 - t) (hF _ hs0 hs1) hE' + (hFb (1 - t) (by push_cast; linarith) (by push_cast; linarith)) + intro t ht ht1 + have htC0 : (0 : ℝ) ≤ ((tC0 : ℚ) : ℝ) := by unfold tC0; norm_num + have hs0 : (0 : ℝ) ≤ 1 - t := by linarith + have hs1 : 1 - t ≤ 1 := by linarith + have hu1 : (1 : ℝ) ≤ (2 : ℝ) ^ (1 - t) := Real.one_le_rpow (by norm_num) hs0 + have hu2 : (2 : ℝ) ^ (1 - t) ≤ 2 := by + have := Real.rpow_le_rpow_of_exponent_le (show (1 : ℝ) ≤ 2 by norm_num) hs1; simpa using this + have hE0 : 0 ≤ E (1 - t) := + le_trans (mul_nonneg (by linarith) (Nat.cast_nonneg st)) (hst _ hs0 hs1) + rcases le_or_gt (1 / 10 : ℝ) t with h10 | h10 + · have h2 := invoice_F (1 - t) (caller 6 7) n 17 + have h3 := invoice_F (1 - t) (caller 6 7) natBaseC 17 + have h4 := natBaseC_F (1 - t) + push_cast at h2 h3 + have h1 := own56_floor (1 - t) hs0 hs1 ks hk hmass hmd mr st hmr (Finv (1 - t) n) (E (1 - t)) 0 (hF _ hs0 hs1) hY + (hst _ hs0 hs1) hE0 + have hc0 : (0 : ℝ) ≤ 88 * (2 - (2 : ℝ) ^ (1 - t)) := by linarith + rw [max_eq_left hc0] at h1 + have h5 := cfC88_neg (1 - t) hs0 (by linarith) + have h6 := base88_eq (1 - t) + nlinarith + · obtain ⟨sp0, sp1, sp2, sp3⟩ := hspTab + obtain ⟨cs0, cs1, cs2, cs3⟩ := hcstTab + obtain ⟨un0, un1, un2, un3⟩ := hunitTab + have q01 : tC0 ≤ tC1 := by unfold tC0 tC1; norm_num + have q12 : tC1 ≤ tC2 := by unfold tC1 tC2; norm_num + have q23 : tC2 ≤ tC3 := by unfold tC2 tC3; norm_num + have q3 : tC3 ≤ 1 / 10 := by unfold tC3; norm_num + have lcp0 : ∀ q : ℚ, q = lcpC0 ∨ q = lcpC1 ∨ q = lcpC2 ∨ q = lcpC3 → 0 ≤ q := by + intro q h; unfold lcpC0 lcpC1 lcpC2 lcpC3 at h; rcases h with h | h | h | h <;> rw [h] <;> norm_num + have cH0 : ∀ q : ℚ, q = cHC0 ∨ q = cHC1 ∨ q = cHC2 ∨ q = cHC3 → 0 ≤ q := by + intro q h; unfold cHC0 cHC1 cHC2 cHC3 at h; rcases h with h | h | h | h <;> rw [h] <;> norm_num + have e1 : ((tC0 : ℚ) : ℝ) ≤ ((tC1 : ℚ) : ℝ) := by exact_mod_cast q01 + have e2 : ((tC1 : ℚ) : ℝ) ≤ ((tC2 : ℚ) : ℝ) := by exact_mod_cast q12 + have e3 : ((tC2 : ℚ) : ℝ) ≤ ((tC3 : ℚ) : ℝ) := by exact_mod_cast q23 + by_cases k1 : t ≤ ((tC1 : ℚ) : ℝ) + · exact piece tC0 tC1 lcpC0 sgC0 sigC0 (by unfold sgC0; norm_num) (le_refl _) q01 (by linarith) (lcp0 _ (Or.inl rfl)) + (tab_piece spF cstF tC0 tC1 lcpC0 cHC0 spFloC0 unitLoC0 (lcp0 _ (Or.inl rfl)) (cH0 _ (Or.inl rfl)) (le_refl _) q01 (by linarith) + hspMono hcstMono sp0 cs0 un0 tabC0.1 tabC0.2) + (hFbC_of tC0 tC1 LC0 (by unfold tC1; norm_num) q01 (by unfold tC0 sC; norm_num) (by unfold tC0; norm_num) ptC0) t ht k1 + by_cases k2 : t ≤ ((tC2 : ℚ) : ℝ) + · exact piece tC1 tC2 lcpC1 sgC1 sigC1 (by unfold sgC1; norm_num) q01 q12 (by linarith) (lcp0 _ (Or.inr (Or.inl rfl))) + (tab_piece spF cstF tC1 tC2 lcpC1 cHC1 spFloC1 unitLoC1 (lcp0 _ (Or.inr (Or.inl rfl))) (cH0 _ (Or.inr (Or.inl rfl))) q01 q12 (by linarith) + hspMono hcstMono sp1 cs1 un1 tabC1.1 tabC1.2) + (hFbC_of tC1 tC2 LC1 (by unfold tC2; norm_num) q12 (by unfold tC1 sC; norm_num) (by unfold tC1; norm_num) ptC1) t + (by push Not at k1; exact k1.le) k2 + by_cases k3 : t ≤ ((tC3 : ℚ) : ℝ) + · exact piece tC2 tC3 lcpC2 sgC2 sigC2 (by unfold sgC2; norm_num) (le_trans q01 q12) q23 (by linarith) (lcp0 _ (Or.inr (Or.inr (Or.inl rfl)))) + (tab_piece spF cstF tC2 tC3 lcpC2 cHC2 spFloC2 unitLoC2 (lcp0 _ (Or.inr (Or.inr (Or.inl rfl)))) (cH0 _ (Or.inr (Or.inr (Or.inl rfl)))) + (le_trans q01 q12) q23 (by linarith) hspMono hcstMono sp2 cs2 un2 tabC2.1 tabC2.2) + (hFbC_of tC2 tC3 LC2 (by unfold tC3; norm_num) q23 (by unfold tC2 sC; norm_num) (by unfold tC2; norm_num) ptC2) t + (by push Not at k2; exact k2.le) k3 + · have h110 : (((1 / 10 : ℚ)) : ℝ) = 1 / 10 := by norm_num + refine piece tC3 (1 / 10) lcpC3 sgC3 ?_ (by unfold sgC3; norm_num) (le_trans q01 (le_trans q12 q23)) q3 (le_refl _) + (lcp0 _ (Or.inr (Or.inr (Or.inr rfl)))) ?_ ?_ t (by push Not at k3; exact k3.le) (by push_cast; exact h10.le) + · rw [show (1 - 1 / 10 : ℚ) = 9 / 10 by norm_num]; exact sigC3 + · refine tab_piece spF cstF tC3 (1 / 10) lcpC3 cHC3 spFloC3 unitLoC3 (lcp0 _ (Or.inr (Or.inr (Or.inr rfl)))) (cH0 _ (Or.inr (Or.inr (Or.inr rfl)))) + (le_trans q01 (le_trans q12 q23)) q3 (le_refl _) hspMono hcstMono sp3 ?_ ?_ tabC3.1 tabC3.2 + · rw [h110]; exact cs3 + · rw [h110]; exact un3 + · intro s hs1' hs2' + have hsC' : s ≤ ((sC : ℚ) : ℝ) := by + have : (1 : ℚ) - tC3 ≤ sC := by unfold tC3 sC; norm_num + have h' : (((1 - tC3 : ℚ)) : ℝ) ≤ ((sC : ℚ) : ℝ) := by exact_mod_cast this + linarith + have h9 : (9 / 10 : ℝ) ≤ s := by + have : ((((1 - 1 / 10 : ℚ)) : ℚ) : ℝ) = 9 / 10 := by norm_num + linarith + have := cfC_neg s h9 hsC' + have h7 : ((liftC : ℚ) : ℝ) ≤ 17 * (((lcpC3 - 5 * sgC3 : ℚ)) : ℝ) := by + have : liftC ≤ 17 * LC3 := LC3_ge + exact_mod_cast this + linarith + +end CongestionNative + +#print axioms CongestionNative.E_lower_cap_om +#print axioms CongestionNative.branchC_om +#print axioms CongestionNative.hcong_of_capclass +#print axioms CongestionNative.unit_mono +#print axioms CongestionNative.tab_piece +#print axioms CongestionNative.ceiling_native diff --git a/research/p104-tiered-ceiling/lean/Nov15/CongestionNative.md b/research/p104-tiered-ceiling/lean/Nov15/CongestionNative.md new file mode 100644 index 0000000000..ea9a98b175 --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/CongestionNative.md @@ -0,0 +1,33 @@ +# CongestionNative.lean (+ CongestionNativeTab.lean, PathCut.lean): the native-covering ceiling kappa <= .0136564 +Copy of the own56 half of CongestionI3Dual*.lean (shipped files untouched), with the HC1-HC4 / AUD / AUD2 edits. Kernel only: no sorry, no native_decide; `#print axioms` of every theorem = [propext, Classical.choice, Quot.sound]. Builds (runlean.sh, one at a time): CongestionNativeTab 10 s / 1.3 GB, PathCut 4 s / 1.4 GB, CongestionNative 11 s / 3.0 GB. + +## What changed against `ceiling_C2` (all done) +- hcong* has the owned surplus on the right: `Omega ks mr s = dprice ks s + mr - (6*9^s+10)`; ks = 24 descents + 13 non-unit rises (sum 102), mr = 10 unit rises (AUD FIX-1; the literal split gives Omega 16.1 < 24.8 and is out of class); stated only for s in [.9, 1 - tC0]. +- `hE` generalised to `Lj <= E + Omega` (`E_lower_cap_om`, `branchC_om`). Omega cancels, so tC0 = .0136564 is unchanged. `branchC_om` needs no ks-hypotheses; hk/hmass/hmd/hmr are used only in the t >= .1 branch (own56_floor, 88c). +- ONE J: a single `J : Finset (ℕ × ℕ)` in hcong, hdist, hJ. It is J^arr (the arrival residual) by interpretation; Lean cannot see that, it is a name for the set the data hypotheses are about. +- FIX C: `Rank8C56`, `Prov`, `PlaneSep`, `MV` are gone. No bare `Prop` stands in for a condition. `ell`, `corr`, `cap` are concrete: `ellC spF s = min (spF (1-s)) (capC s)`, `capC s = (9^s-8^s)/48`, `corrC cstF s = 8 * cstF (1-s)`. +- `LcTabC` is no longer a hypothesis: it is DERIVED (`tab_piece`, `unit_mono` proved) from the rational tables of CongestionNativeTab (outward-rounded, emitted from hc9's 80-digit Decimals; the arithmetic `lcp_j + 8 cH_j <= 1936 min(spFlo_j, unitLo_j/48)` is norm_num-proved) and the hypotheses 11-13 below. +- PathCut.lean: `path_cut` PROVED (abstract: preorder of charts, monotone `Hold`, public edges ascend, owned edges NESTED (FIX A), confinement to G; conclusion: legal path, or a first owned strict descent dropping u_s with all earlier charts holding u_s and c_i <= G). `nested_needed`: Lean counterexample (lateral owned move {0} -> {1}) showing the nestedness premise cannot be dropped. `transported_card_le`: |Jt| <= 48 |V| from the 48-law and "every transported cell lies in cells(visit)". +- `hcong_of_capclass` PROVED: legal cells (charge `Pub + cst*Rm`) + transported cells (`<= 48 Nf`, cap U/48) + Cap class `cst (Rm-8) + U Nf <= Omega` give hcong*. It is the accounting of HC1 sec. 2, not used inside `ceiling_native` (which takes hcong* itself). +No paper statement was found false as written. Known and already encoded: hcong* fails for the natives at t > ~.507 (hence the s-range); the literal ks/mr split is out of class (hence FIX-1). + +## `ceiling_native`: EVERY hypothesis (status for st1 / #7637 / x1t2a; "Lean" = what the kernel checked) +Lean treats R, n, ks, mr, st, E, J, distF, spF, cstF as abstract data. The statement is: IF the listed facts hold for these objects THEN F(1-t, invoice (caller 6 7) n 17) < 0 for t in [tC0, 1]. **That st1, #7637 and x1t2a satisfy the hypotheses (class membership) rests on the computed facts below, not on Lean.** One owned layer is shared by all three words (one data point, not three). +1. hmono, hd9 (public registers ascend, end <= 9): natives: computed fact (0 non-ascending public moves; WHOLEFLOOR/hcong/audit/au2.py, audit2/aud2a.py). +2. hmix (<= 5 mixed registers): natives: computed fact (hmix = 5, aud2a.py). +3. hk, hmass, hmd, hmr (ks/mr split, ranks <= 6 in [1,9], sum 102 >= 56, length 37 >= 8, mr 10 >= 8): natives: computed fact (au1.py, aud2a.py). +4. hF (F-currency identity, equality up to float noise): natives: computed fact (hc6.py, aud2a.py; needs all 400 mains to span 8). +5. hY (104 <= st + 47, st = 1266): natives: computed fact (aud2a.py). +6. hst (slack >= 158 on the grid; 0 only at s = 1): natives: computed fact (hc6.py, aud2a.py). +7. hEex (E >= sum of register excesses; identity): proved as an identity on the natives (hc6.py); open as a general lemma outside the natives. +8. **hcong\*** (sum_J min(dist,cap) - 8 cst <= sum_pub c2 + Omega, s in [.9, 1-tC0]): paper-proved on the Cap class from Path-Cut + I3 + rise charge (PV1 sec. 3, HC1 sec. 2); in Lean only `path_cut`, `transported_card_le`, `hcong_of_capclass` (the combinatorial/arithmetic parts) are proved; the register-machine facts (SP span law, D_t-confined ADD path, I3 distance bound) are NOT formalised. Natives: computed fact: Cap margin Omega - cst(Rm-8) - U Nf >= 19.356 on [.9, 1-tC0] (Omega 47.995, Nf 24, Rm 56); 6124 public moves nested strict ascents, 47 owned moves nested (23 up, 24 down), 207,881 ADDs same chart; all 4962 cells have a legal owned-descent-free path (WHOLEFLOOR/hcong/audit/au1.py, audit2/aud2a.py, prov/pv1-pv4.py). 48-law: computed exhaustively (aud2d.py, max n*m = 48 over all 1,398,491 port-spanned subspaces of dim <= 4; natives max 24, hc8.py). +9. hdist (spF(1-s) <= distF s p for p in J): paper-proved (I3 path bound, ID1, audited); Lean: hypothesis. Natives: covered by the same computed census as 8. +10. **hJ (1936 <= |J^arr|)**: HYPOTHESIS, and for the general Desc56 class a CONJECTURE (AUD2 FIX B: rigidity is numerical, span-form L1-L3 and shared carriers open). Natives: computed fact: |J^arr| = 4962 (aud2b.py exact mod 2^61-1; hc11.py; 2536 forced cells on route flags). +11. hspMono, hcstMono (spF, cst nondecreasing in t on [tC0, 1/10]): paper-proved (HC3: psi = x^s ln x convex, superadditive, so c2 nondecreasing in t); Lean: NOT proved (spF is a min over a 230+dual shape DAG, not defined in Lean); kept as named hypotheses. +12. hspTab, hcstTab (spFlo_j <= spF(tC_j); cst(t_{j+1}) <= cH_j): computed fact, outward-rounded (hc9.py / hc9.log "ALL TABLE ENTRIES CERTIFIED", relative slack ~1e-9); Lean: hypotheses over certified rationals, arithmetic proved (CongestionNativeTab). +13. hunitTab (unitLo_j <= 9^s - 8^s at s = 1 - t_{j+1}): computed fact (hc9.py unit_lo, Decimal 80 digits, outward); Lean: hypothesis (rpow numerics not kernel-checked). +Proved inside Lean (not hypotheses): sigma certificates sigC0..3, F_base point enclosures ptC0..2, tail cfC_neg/cfC88_neg, own56_floor, two-sided I3 (`E_lower_cap_om`), branches, table derivation. + +## Not covered / open +- Class extension (Desc56 in general, >= 9-row and network decoders, non-Desc56 words): open; Rank8C56 rigidity [Q] enters only through hJ. +- Hypotheses 8, 9, 11 are the formalisation gaps (statements about the register machine and the shape DAG); 10 is a conjecture beyond the natives; 12-13 are certified numerics outside the kernel. diff --git a/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeJ.lean b/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeJ.lean new file mode 100644 index 0000000000..67279ebd4c --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeJ.lean @@ -0,0 +1,213 @@ +import Nov15.CongestionNative +import Nov15.CongestionNativeJSig0 +import Nov15.CongestionNativeJSig1 +import Nov15.CongestionNativeJSig2 +import Nov15.CongestionNativeJPt0 +import Nov15.CongestionNativeJPt1 +import Nov15.CongestionNativeJPt2 +import Nov15.CongestionNativeJD +import Nov15.CongestionNativeJUnit + +/-! +CONGESTION-NATIVE-J: `ceiling_native` with the junk count hypothesis raised to `hJ : 4962 ≤ |J|` +(the COMPUTED |J^arr| of the natives st1 / #7637 / x1t2a / #7660-e1). Conclusion: F(1 - t, invoice (caller 6 7) n 17) < 0 for t in [tJ0, 1], +tJ0 = .0118103, i.e. kappa <= .0118103 (own56, m <= 5) for every word satisfying the hypotheses. +* [tC0, 1]: `ceiling_native` itself (its hypotheses are restrictions of the ones here; its unit table is now kernel-proved, `unit_of_Fup`). +* [tJ0, tC0]: three new pieces (CongestionNativeJ{Defs,Sig*,Pt*,D,Unit}): kernel sigma certificates, kernel F_base point enclosures, + kernel derivative bound of F_base on [.93, 1 - tJ0], kernel unit lower bounds, norm_num table arithmetic with N = 4962. +Hypotheses that are still data (same status as in ceiling_native): hcong*, hdist (now on s in [.9, 1 - tJ0]), hJ (now 4962), hspMono/hcstMono +(now on [tJ0, 1/10]), hspTab/hcstTab (+ the three new spF / cst endpoint brackets). hunitTab is GONE (kernel). +The junk count `hJ`, `hcong` and `hdist` all refer to the same `J`; Lean does not tie `J` to any word. -/ +namespace CongestionNative +open NumCertK JointCeiling CallerCost CongestionI3 CongestionI3Dual Finset + +/-- kernel unit lower bound: `lo <= 9^(1-t) - 8^(1-t)` from a `Fup` enclosure of `8^s - 9^s`. -/ +theorem unit_of_Fup (t lo : ℚ) (h0 : 0 ≤ 1 - t) (h1 : 1 - t ≤ 1) (h : Fup unitCF (1 - t) (1 - t) < -lo) : + (lo : ℝ) ≤ (9 : ℝ) ^ (1 - (t : ℝ)) - (8 : ℝ) ^ (1 - (t : ℝ)) := by + have hF := Fc_le unitCF unitCF_ok (1 - t) (1 - t) h0 h1 (((1 - t : ℚ)) : ℝ) (le_refl _) (le_refl _) + have h2 : ((Fup unitCF (1 - t) (1 - t) : ℚ) : ℝ) < ((-lo : ℚ) : ℝ) := by exact_mod_cast h + have hc : (((1 - t : ℚ)) : ℝ) = 1 - (t : ℝ) := by push_cast; ring + rw [hc] at hF + have e : Fc unitCF (1 - (t : ℝ)) = (8 : ℝ) ^ (1 - (t : ℝ)) - (9 : ℝ) ^ (1 - (t : ℝ)) := by + simp [Fc, unitCF]; ring + rw [e] at hF + push_cast at h2 + linarith + +/-- two-sided I3 with a general junk count `Nn` in place of 1936. -/ +theorem E_lower_cap_omN {ι : Type*} [DecidableEq ι] (R : Finset ι) (n : ι → ℕ) (d : ι → ℕ → ℕ) (J : Finset (ℕ × ℕ)) (dist : ℕ × ℕ → ℝ) + (E s cap corr ell σ Om : ℝ) (m Nn : ℕ) + (hmono : ∀ r ∈ R, ∀ i < n r, d r i ≤ d r (i + 1)) (hd9 : ∀ r ∈ R, d r (n r) ≤ 9) + (hm : (R.filter fun r => Mixed d n r).card ≤ m) (hσ0 : 0 ≤ σ) + (hσ : ∀ a b : ℕ, 1 ≤ a → a ≤ b → b ≤ 8 → c2 (gs s) (a : ℝ) (b : ℝ) ≤ σ) + (hcong : ∑ p ∈ J, min (dist p) cap - corr ≤ ∑ r ∈ R, ∑ i ∈ range (n r), c2 (gs s) (lev d r i) (lev d r (i + 1)) + Om) + (hEex : ∑ r ∈ R, ex (gs s) (lev d r) (n r) ≤ E) (hdist : ∀ p ∈ J, ell ≤ min (dist p) cap) (hJ : Nn ≤ J.card) (hell : 0 ≤ ell) : + (Nn : ℝ) * ell - corr - m * σ ≤ E + Om := by + have h1 := sum_all_c2_le (gs s) (gs_zero s) R n d hmono hd9 m hm σ hσ0 hσ + have h2 := Finset.card_nsmul_le_sum J (fun p => min (dist p) cap) ell hdist + rw [nsmul_eq_mul] at h2 + have hj : (Nn : ℝ) ≤ J.card := by exact_mod_cast hJ + have h3 : (Nn : ℝ) * ell ≤ (J.card : ℝ) * ell := mul_le_mul_of_nonneg_right hj hell + linarith + +/-- one t-piece `[a, b]` with N = 4962 (copy of `tab_piece`, domain [tJ0, 1/10]). -/ +theorem tab_pieceJ (spF cstF : ℝ → ℝ) (a b : ℚ) (lcp cH spLo unLo : ℚ) (hlcp : 0 ≤ lcp) (hcH : 0 ≤ cH) (ha0 : tJ0 ≤ a) (hab : a ≤ b) (hb : b ≤ 1 / 10) + (hmS : MonotoneOn spF (Set.Icc ((tJ0 : ℚ) : ℝ) (1 / 10))) (hmC : MonotoneOn cstF (Set.Icc ((tJ0 : ℚ) : ℝ) (1 / 10))) + (hsp : (spLo : ℝ) ≤ spF (a : ℝ)) (hcs : cstF (b : ℝ) ≤ cH) + (hun : (unLo : ℝ) ≤ (9 : ℝ) ^ (1 - (b : ℝ)) - (8 : ℝ) ^ (1 - (b : ℝ))) + (hn1 : lcp + 8 * cH ≤ 4962 * spLo) (hn2 : lcp + 8 * cH ≤ 4962 * (unLo / 48)) : + ∀ s : ℝ, ((1 - b : ℚ) : ℝ) ≤ s → s ≤ ((1 - a : ℚ) : ℝ) → (lcp : ℝ) ≤ 4962 * ellC spF s - corrC cstF s ∧ 0 ≤ ellC spF s := by + intro s h1 h2 + push_cast at h1 h2 + have ha' : ((tJ0 : ℚ) : ℝ) ≤ a := by exact_mod_cast ha0 + have hab' : (a : ℝ) ≤ b := by exact_mod_cast hab + have hb' : (b : ℝ) ≤ 1 / 10 := by + have := (Rat.cast_le (K := ℝ)).mpr hb + push_cast at this; exact this + have htl : (a : ℝ) ≤ 1 - s := by linarith + have htu : 1 - s ≤ (b : ℝ) := by linarith + have hspt : spF a ≤ spF (1 - s) := hmS ⟨ha', by linarith⟩ ⟨by linarith, by linarith⟩ htl + have hcst : cstF (1 - s) ≤ cstF b := hmC ⟨by linarith, by linarith⟩ ⟨by linarith, hb'⟩ htu + have hcap : (unLo : ℝ) / 48 ≤ capC s := by + have := unit_mono (1 - b) s (by linarith) h1 + unfold capC; linarith + have hell : min (spLo : ℝ) ((unLo : ℝ) / 48) ≤ ellC spF s := by + unfold ellC + exact le_min (le_trans (min_le_left _ _) (by linarith)) (le_trans (min_le_right _ _) hcap) + have hcorr : corrC cstF s ≤ 8 * (cH : ℝ) := by unfold corrC; linarith + have hn1' : (lcp : ℝ) + 8 * cH ≤ 4962 * spLo := by exact_mod_cast hn1 + have hn2' : (lcp : ℝ) + 8 * cH ≤ 4962 * ((unLo : ℝ) / 48) := by exact_mod_cast hn2 + have hl0 : (0 : ℝ) ≤ lcp := by exact_mod_cast hlcp + have hc0 : (0 : ℝ) ≤ cH := by exact_mod_cast hcH + rcases le_total (spLo : ℝ) ((unLo : ℝ) / 48) with hh | hh + · rw [min_eq_left hh] at hell; exact ⟨by linarith, by linarith⟩ + · rw [min_eq_right hh] at hell; exact ⟨by linarith, by linarith⟩ + +theorem cfC_monoOnJ (s s' : ℝ) (h1 : (93 / 100 : ℝ) ≤ s) (hss : s ≤ s') (h2 : s' ≤ ((1 - tJ0 : ℚ) : ℝ)) : Fc cfC s ≤ Fc cfC s' := + Fc_monoOn cfC cfC_ok (93 / 100) (1 - tJ0) (by norm_num) (by unfold tJ0; norm_num) cfC_dJ s s' + (by rw [show (((93 / 100 : ℚ)) : ℝ) = 93 / 100 by norm_num]; exact h1) hss h2 + +theorem hFbJ_of (a b L : ℚ) (hb93 : 93 / 100 ≤ 1 - b) (hab : a ≤ b) (haJ : tJ0 ≤ a) + (hpt : Fup cfC (1 - a) (1 - a) < 17 * L) : + ∀ s : ℝ, ((1 - b : ℚ) : ℝ) ≤ s → s ≤ ((1 - a : ℚ) : ℝ) → Fc cfC s < 17 * (L : ℝ) := by + intro s h1 h2 + have hb : (((93 / 100 : ℚ)) : ℝ) ≤ s := le_trans (by exact_mod_cast hb93) h1 + have hb' : (93 / 100 : ℝ) ≤ s := by rwa [show (((93 / 100 : ℚ)) : ℝ) = 93 / 100 by norm_num] at hb + have haA : (1 - a : ℚ) ≤ 1 - tJ0 := by linarith + have hm := cfC_monoOnJ s ((1 - a : ℚ) : ℝ) hb' h2 (by exact_mod_cast haA) + have hJ0 : (0 : ℚ) ≤ tJ0 := by unfold tJ0; norm_num + exact lt_of_le_of_lt hm (pt_of_Fup cfC cfC_ok (1 - a) L (by linarith) (by linarith) hpt) + +/-- **native-covering ceiling at the computed junk count.** Same statement as `ceiling_native` with `hJ : 4962 ≤ |J|`; hcong*/hdist on +s in [.9, 1 - tJ0]; monotonicity on [tJ0, 1/10]; three more endpoint brackets of spF / cst. Conclusion on t in [tJ0, 1]: kappa <= .0118103. -/ +theorem ceiling_native_J {ι : Type*} [DecidableEq ι] + (R : Finset ι) (nR : ι → ℕ) (dR : ι → ℕ → ℕ) + (hmono : ∀ r ∈ R, ∀ i < nR r, dR r i ≤ dR r (i + 1)) (hd9 : ∀ r ∈ R, dR r (nR r) ≤ 9) + (hmix : (R.filter fun r => Mixed dR nR r).card ≤ 5) + (n : Inv) (ks : List ℕ) (mr st : ℕ) (E : ℝ → ℝ) (J : Finset (ℕ × ℕ)) (distF : ℝ → ℕ × ℕ → ℝ) (spF cstF : ℝ → ℝ) + (hk : ∀ k ∈ ks, 1 ≤ k ∧ k ≤ 9) (hmass : 56 ≤ ks.sum) (hmd : 8 ≤ ks.length) (hmr : 8 ≤ mr) + (hF : ∀ s, 0 ≤ s → s ≤ 1 → Finv s n ≤ -400 * (8 : ℝ) ^ s - dprice ks s - mr - E s) + (hY : 104 ≤ st + (ks.length + mr)) + (hst : ∀ s, 0 ≤ s → s ≤ 1 → (2 - (2 : ℝ) ^ s) * st ≤ E s) + (hEex : ∀ s, 0 ≤ s → s ≤ 1 → ∑ r ∈ R, ex (gs s) (lev dR r) (nR r) ≤ E s) + (hcong : ∀ s, 9 / 10 ≤ s → s ≤ 1 - ((tJ0 : ℚ) : ℝ) → + ∑ p ∈ J, min (distF s p) (capC s) - corrC cstF s ≤ + ∑ r ∈ R, ∑ i ∈ range (nR r), c2 (gs s) (lev dR r i) (lev dR r (i + 1)) + Omega ks mr s) + (hdist : ∀ s, 9 / 10 ≤ s → s ≤ 1 - ((tJ0 : ℚ) : ℝ) → ∀ p ∈ J, spF (1 - s) ≤ distF s p) + (hJ : 4962 ≤ J.card) + (hspMono : MonotoneOn spF (Set.Icc ((tJ0 : ℚ) : ℝ) (1 / 10))) + (hcstMono : MonotoneOn cstF (Set.Icc ((tJ0 : ℚ) : ℝ) (1 / 10))) + (hspTab : ((spFloC0 : ℚ) : ℝ) ≤ spF ((tC0 : ℚ) : ℝ) ∧ ((spFloC1 : ℚ) : ℝ) ≤ spF ((tC1 : ℚ) : ℝ) ∧ + ((spFloC2 : ℚ) : ℝ) ≤ spF ((tC2 : ℚ) : ℝ) ∧ ((spFloC3 : ℚ) : ℝ) ≤ spF ((tC3 : ℚ) : ℝ)) + (hcstTab : cstF ((tC1 : ℚ) : ℝ) ≤ ((cHC0 : ℚ) : ℝ) ∧ cstF ((tC2 : ℚ) : ℝ) ≤ ((cHC1 : ℚ) : ℝ) ∧ + cstF ((tC3 : ℚ) : ℝ) ≤ ((cHC2 : ℚ) : ℝ) ∧ cstF (1 / 10) ≤ ((cHC3 : ℚ) : ℝ)) + (hspTabJ : ((spFloJ0 : ℚ) : ℝ) ≤ spF ((tJ0 : ℚ) : ℝ) ∧ ((spFloJ1 : ℚ) : ℝ) ≤ spF ((tJ1 : ℚ) : ℝ) ∧ + ((spFloJ2 : ℚ) : ℝ) ≤ spF ((tJ2 : ℚ) : ℝ)) + (hcstTabJ : cstF ((tJ1 : ℚ) : ℝ) ≤ ((cHJ0 : ℚ) : ℝ) ∧ cstF ((tJ2 : ℚ) : ℝ) ≤ ((cHJ1 : ℚ) : ℝ) ∧ + cstF ((tC0 : ℚ) : ℝ) ≤ ((cHJ2 : ℚ) : ℝ)) : + ∀ t : ℝ, ((tJ0 : ℚ) : ℝ) ≤ t → t ≤ 1 → Finv (1 - t) (invoice (caller 6 7) n 17) < 0 := by + have qJC : tJ0 ≤ tC0 := by unfold tJ0 tC0; norm_num + have eJC : ((tJ0 : ℚ) : ℝ) ≤ ((tC0 : ℚ) : ℝ) := by exact_mod_cast qJC + intro t ht ht1 + rcases le_or_gt ((tC0 : ℚ) : ℝ) t with hC | hC + · -- [tC0, 1]: the shipped `ceiling_native` + have u0 := unit_of_Fup tC1 unitLoC0 (by unfold tC1; norm_num) (by unfold tC1; norm_num) unitC0' + have u1 := unit_of_Fup tC2 unitLoC1 (by unfold tC2; norm_num) (by unfold tC2; norm_num) unitC1' + have u2 := unit_of_Fup tC3 unitLoC2 (by unfold tC3; norm_num) (by unfold tC3; norm_num) unitC2' + have u3 := unit_of_Fup (1 / 10) unitLoC3 (by norm_num) (by norm_num) unitC3' + have h110 : (((1 / 10 : ℚ)) : ℝ) = 1 / 10 := by norm_num + rw [h110] at u3 + exact ceiling_native R nR dR hmono hd9 hmix n ks mr st E J distF spF cstF hk hmass hmd hmr hF hY hst hEex + (fun s h1 h2 => hcong s h1 (by linarith)) (fun s h1 h2 => hdist s h1 (by linarith)) (le_trans (by norm_num) hJ) + (hspMono.mono (Set.Icc_subset_Icc eJC (le_refl _))) (hcstMono.mono (Set.Icc_subset_Icc eJC (le_refl _))) + hspTab hcstTab ⟨u0, u1, u2, u3⟩ t hC ht1 + · -- [tJ0, tC0]: three new pieces with N = 4962 + have piece : ∀ (a b lcp σ : ℚ), sigOK (1 - b) (1 - a) σ = true → 0 ≤ σ → tJ0 ≤ a → a ≤ b → b ≤ tC0 → 0 ≤ lcp → + (∀ s : ℝ, ((1 - b : ℚ) : ℝ) ≤ s → s ≤ ((1 - a : ℚ) : ℝ) → (lcp : ℝ) ≤ 4962 * ellC spF s - corrC cstF s ∧ 0 ≤ ellC spF s) → + (∀ s : ℝ, ((1 - b : ℚ) : ℝ) ≤ s → s ≤ ((1 - a : ℚ) : ℝ) → Fc cfC s < 17 * (((lcp - 5 * σ : ℚ)) : ℝ)) → + ∀ t : ℝ, (a : ℝ) ≤ t → t ≤ (b : ℝ) → Finv (1 - t) (invoice (caller 6 7) n 17) < 0 := by + intro a b lcp σ hσc hσ0 ha0 hab hb hl0 hLcp hFb t h1 h2 + have ha0q : (0 : ℚ) ≤ a := le_trans (by unfold tJ0; norm_num) ha0 + have ha0' : ((tJ0 : ℚ) : ℝ) ≤ a := by exact_mod_cast ha0 + have hbC : (b : ℝ) ≤ ((tC0 : ℚ) : ℝ) := by exact_mod_cast hb + have hC1 : ((tC0 : ℚ) : ℝ) ≤ 1 / 10 := by + have : tC0 ≤ 1 / 10 := by unfold tC0; norm_num + have := (Rat.cast_le (K := ℝ)).mpr this + push_cast at this; exact this + have hb' : (b : ℝ) ≤ 1 / 10 := le_trans hbC hC1 + have hA0 : (0 : ℝ) ≤ a := by exact_mod_cast ha0q + have hs0 : 0 ≤ 1 - t := by linarith + have hs1 : 1 - t ≤ 1 := by linarith + have hbq : b ≤ 1 / 10 := le_trans hb (by unfold tC0; norm_num) + have hσ : ∀ a' b' : ℕ, 1 ≤ a' → a' ≤ b' → b' ≤ 8 → c2 (gs (1 - t)) (a' : ℝ) (b' : ℝ) ≤ (σ : ℝ) := by + intro a' b' h1' h2' h3' + exact sig_of_ok (1 - b) (1 - a) σ hσc (by linarith) (by linarith) hσ0 (1 - t) + (by push_cast; linarith) (by push_cast; linarith) a' b' h1' h2' h3' + have hLcp' := hLcp (1 - t) (by push_cast; linarith) (by push_cast; linarith) + have hslo : (9 / 10 : ℝ) ≤ 1 - t := by linarith + have hshi : 1 - t ≤ 1 - ((tJ0 : ℚ) : ℝ) := by linarith + have hell : 0 ≤ ellC spF (1 - t) := hLcp'.2 + have hE := E_lower_cap_omN R nR dR J (distF (1 - t)) (E (1 - t)) (1 - t) (capC (1 - t)) (corrC cstF (1 - t)) (ellC spF (1 - t)) + (σ : ℝ) (Omega ks mr (1 - t)) 5 4962 hmono hd9 hmix (by exact_mod_cast hσ0) hσ (hcong (1 - t) hslo hshi) (hEex _ hs0 hs1) + (fun p hp => le_min (le_trans (min_le_left _ _) (hdist (1 - t) hslo hshi p hp)) (min_le_right _ _)) hJ hell + have hE' : (((lcp - 5 * σ : ℚ)) : ℝ) ≤ E (1 - t) + Omega ks mr (1 - t) := by + push_cast; push_cast at hE; linarith [hLcp'.1] + exact branchC_om n ks mr (E (1 - t)) _ (1 - t) (hF _ hs0 hs1) hE' + (hFb (1 - t) (by push_cast; linarith) (by push_cast; linarith)) + obtain ⟨sp0, sp1, sp2⟩ := hspTabJ + obtain ⟨cs0, cs1, cs2⟩ := hcstTabJ + have q01 : tJ0 ≤ tJ1 := by unfold tJ0 tJ1; norm_num + have q12 : tJ1 ≤ tJ2 := by unfold tJ1 tJ2; norm_num + have q2C : tJ2 ≤ tC0 := by unfold tJ2 tC0; norm_num + have qC : tC0 ≤ 1 / 10 := by unfold tC0; norm_num + have un0 := unit_of_Fup tJ1 unitLoJ0 (by unfold tJ1; norm_num) (by unfold tJ1; norm_num) unitJ0 + have un1 := unit_of_Fup tJ2 unitLoJ1 (by unfold tJ2; norm_num) (by unfold tJ2; norm_num) unitJ1 + have un2 := unit_of_Fup tC0 unitLoJ2 (by unfold tC0; norm_num) (by unfold tC0; norm_num) unitJ2 + have l0 : (0 : ℚ) ≤ lcpJ0 := by unfold lcpJ0; norm_num + have l1 : (0 : ℚ) ≤ lcpJ1 := by unfold lcpJ1; norm_num + have l2 : (0 : ℚ) ≤ lcpJ2 := by unfold lcpJ2; norm_num + have c0 : (0 : ℚ) ≤ cHJ0 := by unfold cHJ0; norm_num + have c1 : (0 : ℚ) ≤ cHJ1 := by unfold cHJ1; norm_num + have c2' : (0 : ℚ) ≤ cHJ2 := by unfold cHJ2; norm_num + have e1 : ((tJ1 : ℚ) : ℝ) ≤ ((tJ2 : ℚ) : ℝ) := by exact_mod_cast q12 + by_cases k1 : t ≤ ((tJ1 : ℚ) : ℝ) + · exact piece tJ0 tJ1 lcpJ0 sgJ0 sigJ0 (by unfold sgJ0; norm_num) (le_refl _) q01 (le_trans q12 q2C) l0 + (tab_pieceJ spF cstF tJ0 tJ1 lcpJ0 cHJ0 spFloJ0 unitLoJ0 l0 c0 (le_refl _) q01 (le_trans (le_trans q12 q2C) qC) + hspMono hcstMono sp0 cs0 un0 tabJ0.1 tabJ0.2) + (hFbJ_of tJ0 tJ1 LJ0 (by unfold tJ1; norm_num) q01 (le_refl _) ptJ0) t ht k1 + by_cases k2 : t ≤ ((tJ2 : ℚ) : ℝ) + · exact piece tJ1 tJ2 lcpJ1 sgJ1 sigJ1 (by unfold sgJ1; norm_num) q01 q12 q2C l1 + (tab_pieceJ spF cstF tJ1 tJ2 lcpJ1 cHJ1 spFloJ1 unitLoJ1 l1 c1 q01 q12 (le_trans q2C qC) + hspMono hcstMono sp1 cs1 un1 tabJ1.1 tabJ1.2) + (hFbJ_of tJ1 tJ2 LJ1 (by unfold tJ2; norm_num) q12 q01 ptJ1) t (by push Not at k1; exact k1.le) k2 + · exact piece tJ2 tC0 lcpJ2 sgJ2 sigJ2 (by unfold sgJ2; norm_num) (le_trans q01 q12) q2C (le_refl _) l2 + (tab_pieceJ spF cstF tJ2 tC0 lcpJ2 cHJ2 spFloJ2 unitLoJ2 l2 c2' (le_trans q01 q12) q2C qC + hspMono hcstMono sp2 cs2 un2 tabJ2.1 tabJ2.2) + (hFbJ_of tJ2 tC0 LJ2 (by unfold tC0; norm_num) q2C (le_trans q01 q12) ptJ2) t (by push Not at k2; exact k2.le) hC.le + +end CongestionNative + +#print axioms CongestionNative.unit_of_Fup +#print axioms CongestionNative.E_lower_cap_omN +#print axioms CongestionNative.tab_pieceJ +#print axioms CongestionNative.ceiling_native_J diff --git a/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeJD.lean b/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeJD.lean new file mode 100644 index 0000000000..3060b75a60 --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeJD.lean @@ -0,0 +1,5 @@ +import Nov15.CongestionNativeJDefs +namespace CongestionNative +open NumCertK CongestionI3 CongestionI3Dual +theorem cfC_dJ : 0 < dLo cfC (93 / 100) (1 - tJ0) := by unfold tJ0; decide +kernel +end CongestionNative diff --git a/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeJDefs.lean b/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeJDefs.lean new file mode 100644 index 0000000000..c70a731406 --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeJDefs.lean @@ -0,0 +1,43 @@ +import Nov15.CongestionI3DualConst +import Nov15.CongestionI3NumC1 +import Nov15.CongestionNativeTab + +/-! CONGESTION-NATIVE-J certificates: the three own56 t-pieces on [tJ0, tC0] for the junk count N = 4962. +Source: internal table generators (Decimal 80 digits, +-1e-70 brackets; spF DAG weights rounded DOWN, cst rounded UP, +unit_lo = 9^s lower - 8^s upper; all rounded outward to 14 / 6 / 7 digits). Kernel-checked here: sigma certificates (`sigOK`), F_base point +enclosures (`Fup`), the derivative bound of F_base on [.93, 1 - tJ0], the rational table arithmetic, and ALL unit lower bounds (old and new). -/ +namespace CongestionNative +open NumCertK CongestionI3 CongestionI3Dual + +def tJ0 : ℚ := 118103 / 10 ^ 7 +def tJ1 : ℚ := 118123 / 10 ^ 7 +def tJ2 : ℚ := 120123 / 10 ^ 7 +def sgJ0 : ℚ := 24309 / 500000 +def sgJ1 : ℚ := 25631 / 500000 +def sgJ2 : ℚ := 57 / 800 +def cHJ0 : ℚ := 291901 / 10 ^ 7 +def cHJ1 : ℚ := 296781 / 10 ^ 7 +def cHJ2 : ℚ := 336819 / 10 ^ 7 +def lcpJ0 : ℚ := 27930489 / 10 ^ 6 +def lcpJ1 : ℚ := 2793131 / 10 ^ 5 +def lcpJ2 : ℚ := 28371641 / 10 ^ 6 +def LJ0 : ℚ := lcpJ0 - 5 * sgJ0 +def LJ1 : ℚ := lcpJ1 - 5 * sgJ1 +def LJ2 : ℚ := lcpJ2 - 5 * sgJ2 +/-- lower bounds of spF(tJ_j) -/ +def spFloJ0 : ℚ := 113518785551 / 20000000000000 +def spFloJ1 : ℚ := 17740285593 / 3125000000000 +def spFloJ2 : ℚ := 577208719357 / 100000000000000 +/-- lower bounds of 9^(1-t_{j+1}) - 8^(1-t_{j+1}) (t_{j+1} = tJ1, tJ2, tC0) -/ +def unitLoJ0 : ℚ := 48176347373057 / 50000000000000 +def unitLoJ1 : ℚ := 96291982180651 / 100000000000000 +def unitLoJ2 : ℚ := 95794193417421 / 100000000000000 + +theorem tabJ0 : lcpJ0 + 8 * cHJ0 ≤ 4962 * spFloJ0 ∧ lcpJ0 + 8 * cHJ0 ≤ 4962 * (unitLoJ0 / 48) := by + unfold lcpJ0 cHJ0 spFloJ0 unitLoJ0; constructor <;> norm_num +theorem tabJ1 : lcpJ1 + 8 * cHJ1 ≤ 4962 * spFloJ1 ∧ lcpJ1 + 8 * cHJ1 ≤ 4962 * (unitLoJ1 / 48) := by + unfold lcpJ1 cHJ1 spFloJ1 unitLoJ1; constructor <;> norm_num +theorem tabJ2 : lcpJ2 + 8 * cHJ2 ≤ 4962 * spFloJ2 ∧ lcpJ2 + 8 * cHJ2 ≤ 4962 * (unitLoJ2 / 48) := by + unfold lcpJ2 cHJ2 spFloJ2 unitLoJ2; constructor <;> norm_num + +end CongestionNative diff --git a/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeJPt0.lean b/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeJPt0.lean new file mode 100644 index 0000000000..d28bdf6efc --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeJPt0.lean @@ -0,0 +1,5 @@ +import Nov15.CongestionNativeJDefs +namespace CongestionNative +open NumCertK CongestionI3 CongestionI3Dual +theorem ptJ0 : Fup cfC (1 - tJ0) (1 - tJ0) < 17 * LJ0 := by unfold tJ0 LJ0 lcpJ0 sgJ0; decide +kernel +end CongestionNative diff --git a/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeJPt1.lean b/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeJPt1.lean new file mode 100644 index 0000000000..9bbcfbdafe --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeJPt1.lean @@ -0,0 +1,5 @@ +import Nov15.CongestionNativeJDefs +namespace CongestionNative +open NumCertK CongestionI3 CongestionI3Dual +theorem ptJ1 : Fup cfC (1 - tJ1) (1 - tJ1) < 17 * LJ1 := by unfold tJ1 LJ1 lcpJ1 sgJ1; decide +kernel +end CongestionNative diff --git a/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeJPt2.lean b/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeJPt2.lean new file mode 100644 index 0000000000..885ad815aa --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeJPt2.lean @@ -0,0 +1,5 @@ +import Nov15.CongestionNativeJDefs +namespace CongestionNative +open NumCertK CongestionI3 CongestionI3Dual +theorem ptJ2 : Fup cfC (1 - tJ2) (1 - tJ2) < 17 * LJ2 := by unfold tJ2 LJ2 lcpJ2 sgJ2; decide +kernel +end CongestionNative diff --git a/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeJSig0.lean b/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeJSig0.lean new file mode 100644 index 0000000000..8b0742d04e --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeJSig0.lean @@ -0,0 +1,6 @@ +import Nov15.CongestionI3DualSig +import Nov15.CongestionNativeJDefs +namespace CongestionNative +open NumCertK CongestionI3 CongestionI3Dual +theorem sigJ0 : sigOK (1 - tJ1) (1 - tJ0) sgJ0 = true := by decide +kernel +end CongestionNative diff --git a/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeJSig1.lean b/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeJSig1.lean new file mode 100644 index 0000000000..405bf16d0a --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeJSig1.lean @@ -0,0 +1,6 @@ +import Nov15.CongestionI3DualSig +import Nov15.CongestionNativeJDefs +namespace CongestionNative +open NumCertK CongestionI3 CongestionI3Dual +theorem sigJ1 : sigOK (1 - tJ2) (1 - tJ1) sgJ1 = true := by decide +kernel +end CongestionNative diff --git a/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeJSig2.lean b/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeJSig2.lean new file mode 100644 index 0000000000..19afd04daa --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeJSig2.lean @@ -0,0 +1,6 @@ +import Nov15.CongestionI3DualSig +import Nov15.CongestionNativeJDefs +namespace CongestionNative +open NumCertK CongestionI3 CongestionI3Dual +theorem sigJ2 : sigOK (1 - tC0) (1 - tJ2) sgJ2 = true := by decide +kernel +end CongestionNative diff --git a/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeJUnit.lean b/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeJUnit.lean new file mode 100644 index 0000000000..f4ed40d499 --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeJUnit.lean @@ -0,0 +1,14 @@ +import Nov15.CongestionNativeJDefs +namespace CongestionNative +open NumCertK CongestionI3 CongestionI3Dual +/-- `8^s - 9^s` as an exponential polynomial -/ +def unitCF : CF := [(8, 1), (9, -1)] +theorem unitCF_ok : okR unitCF := by decide +kernel +theorem unitJ0 : Fup unitCF (1 - tJ1) (1 - tJ1) < -unitLoJ0 := by unfold tJ1 unitLoJ0; decide +kernel +theorem unitJ1 : Fup unitCF (1 - tJ2) (1 - tJ2) < -unitLoJ1 := by unfold tJ2 unitLoJ1; decide +kernel +theorem unitJ2 : Fup unitCF (1 - tC0) (1 - tC0) < -unitLoJ2 := by unfold tC0 unitLoJ2; decide +kernel +theorem unitC0' : Fup unitCF (1 - tC1) (1 - tC1) < -unitLoC0 := by unfold tC1 unitLoC0; decide +kernel +theorem unitC1' : Fup unitCF (1 - tC2) (1 - tC2) < -unitLoC1 := by unfold tC2 unitLoC1; decide +kernel +theorem unitC2' : Fup unitCF (1 - tC3) (1 - tC3) < -unitLoC2 := by unfold tC3 unitLoC2; decide +kernel +theorem unitC3' : Fup unitCF (1 - 1 / 10) (1 - 1 / 10) < -unitLoC3 := by unfold unitLoC3; decide +kernel +end CongestionNative diff --git a/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeN.lean b/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeN.lean new file mode 100644 index 0000000000..bbb30b8d3e --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeN.lean @@ -0,0 +1,214 @@ +import Nov15.CongestionNativeJ +import Nov15.CongestionNativeNDefs +import Nov15.CongestionNativeNSig0 +import Nov15.CongestionNativeNSig1 +import Nov15.CongestionNativeNSig2 +import Nov15.CongestionNativeNSig3 +import Nov15.CongestionNativeNSig4 +import Nov15.CongestionNativeNPt +import Nov15.CongestionNativeNUnit + +/-! +CONGESTION-NATIVE-N96: `ceiling_native` / `ceiling_native_J` with the junk count hypothesis lowered to `hJ : 96 <= |J|`, +the value of Law A (JunkLawA.lean) at descending mass 56: 96 = 2 (104 - 56). Conclusion: F(1 - t, invoice (caller 6 7) n 17) < 0 for t in [tN0, 1], +tN0 = .0151027, i.e. kappa <= .0151027 (own56, m <= 5) for every word satisfying the hypotheses (float crossing .0151026, see JunkLawA.md). +Pieces: [tN0, tN1, tN2, tN3, .07, .1] (4 point-form pieces with F_base monotone on [.93, 1 - tN0], one box-form piece on s in [.9, .93]), then t >= .1 as in `ceiling_native`. +Hypotheses are those of `ceiling_native_J` with 4962 -> 96 and the new endpoint brackets (hspTabN, hcstTabN); all unit brackets, sigma certificates, F_base enclosures are kernel. +-/ +namespace CongestionNative +open NumCertK JointCeiling CallerCost CongestionI3 CongestionI3Dual Finset + +/-- one t-piece `[a, b]` with N = 96; `lcp` may be negative (only `0 <= spLo`, `0 <= unLo` are needed for `0 <= ell`). -/ +theorem tab_pieceN (spF cstF : ℝ → ℝ) (a b : ℚ) (lcp cH spLo unLo : ℚ) (hcH : 0 ≤ cH) (hsp0 : 0 ≤ spLo) (hun0 : 0 ≤ unLo) + (ha0 : tN0 ≤ a) (hab : a ≤ b) (hb : b ≤ 1 / 10) + (hmS : MonotoneOn spF (Set.Icc ((tN0 : ℚ) : ℝ) (1 / 10))) (hmC : MonotoneOn cstF (Set.Icc ((tN0 : ℚ) : ℝ) (1 / 10))) + (hsp : (spLo : ℝ) ≤ spF (a : ℝ)) (hcs : cstF (b : ℝ) ≤ cH) + (hun : (unLo : ℝ) ≤ (9 : ℝ) ^ (1 - (b : ℝ)) - (8 : ℝ) ^ (1 - (b : ℝ))) + (hn1 : lcp + 8 * cH ≤ 96 * spLo) (hn2 : lcp + 8 * cH ≤ 96 * (unLo / 48)) : + ∀ s : ℝ, ((1 - b : ℚ) : ℝ) ≤ s → s ≤ ((1 - a : ℚ) : ℝ) → (lcp : ℝ) ≤ 96 * ellC spF s - corrC cstF s ∧ 0 ≤ ellC spF s := by + intro s h1 h2 + push_cast at h1 h2 + have ha' : ((tN0 : ℚ) : ℝ) ≤ a := by exact_mod_cast ha0 + have hab' : (a : ℝ) ≤ b := by exact_mod_cast hab + have hb' : (b : ℝ) ≤ 1 / 10 := by + have := (Rat.cast_le (K := ℝ)).mpr hb + push_cast at this; exact this + have htl : (a : ℝ) ≤ 1 - s := by linarith + have htu : 1 - s ≤ (b : ℝ) := by linarith + have hspt : spF a ≤ spF (1 - s) := hmS ⟨ha', by linarith⟩ ⟨by linarith, by linarith⟩ htl + have hcst : cstF (1 - s) ≤ cstF b := hmC ⟨by linarith, by linarith⟩ ⟨by linarith, hb'⟩ htu + have hcap : (unLo : ℝ) / 48 ≤ capC s := by + have := unit_mono (1 - b) s (by linarith) h1 + unfold capC; linarith + have hell : min (spLo : ℝ) ((unLo : ℝ) / 48) ≤ ellC spF s := by + unfold ellC + exact le_min (le_trans (min_le_left _ _) (by linarith)) (le_trans (min_le_right _ _) hcap) + have hcorr : corrC cstF s ≤ 8 * (cH : ℝ) := by unfold corrC; linarith + have hn1' : (lcp : ℝ) + 8 * cH ≤ 96 * spLo := by exact_mod_cast hn1 + have hn2' : (lcp : ℝ) + 8 * cH ≤ 96 * ((unLo : ℝ) / 48) := by exact_mod_cast hn2 + have hs0' : (0 : ℝ) ≤ spLo := by exact_mod_cast hsp0 + have hu0' : (0 : ℝ) ≤ (unLo : ℝ) / 48 := by + have h : (0 : ℝ) ≤ unLo := by exact_mod_cast hun0 + linarith + have hc0 : (0 : ℝ) ≤ cH := by exact_mod_cast hcH + have hmin0 : (0 : ℝ) ≤ min (spLo : ℝ) ((unLo : ℝ) / 48) := le_min hs0' hu0' + rcases le_total (spLo : ℝ) ((unLo : ℝ) / 48) with hh | hh + · rw [min_eq_left hh] at hell hmin0; exact ⟨by linarith, by linarith⟩ + · rw [min_eq_right hh] at hell hmin0; exact ⟨by linarith, by linarith⟩ + +/-- **no-hJ ceiling, junk count 96.** Same statement as `ceiling_native_J` with `hJ : 96 ≤ J.card`, hcong*/hdist on s in [.9, 1 - tN0], monotonicity on [tN0, 1/10], five spF and five cst endpoint brackets. +Conclusion on t in [tN0, 1]: kappa <= .0151027. -/ +theorem ceiling_native_N96 {ι : Type*} [DecidableEq ι] + (R : Finset ι) (nR : ι → ℕ) (dR : ι → ℕ → ℕ) + (hmono : ∀ r ∈ R, ∀ i < nR r, dR r i ≤ dR r (i + 1)) (hd9 : ∀ r ∈ R, dR r (nR r) ≤ 9) + (hmix : (R.filter fun r => Mixed dR nR r).card ≤ 5) + (n : Inv) (ks : List ℕ) (mr st : ℕ) (E : ℝ → ℝ) (J : Finset (ℕ × ℕ)) (distF : ℝ → ℕ × ℕ → ℝ) (spF cstF : ℝ → ℝ) + (hk : ∀ k ∈ ks, 1 ≤ k ∧ k ≤ 9) (hmass : 56 ≤ ks.sum) (hmd : 8 ≤ ks.length) (hmr : 8 ≤ mr) + (hF : ∀ s, 0 ≤ s → s ≤ 1 → Finv s n ≤ -400 * (8 : ℝ) ^ s - dprice ks s - mr - E s) + (hY : 104 ≤ st + (ks.length + mr)) + (hst : ∀ s, 0 ≤ s → s ≤ 1 → (2 - (2 : ℝ) ^ s) * st ≤ E s) + (hEex : ∀ s, 0 ≤ s → s ≤ 1 → ∑ r ∈ R, ex (gs s) (lev dR r) (nR r) ≤ E s) + (hcong : ∀ s, 9 / 10 ≤ s → s ≤ 1 - ((tN0 : ℚ) : ℝ) → + ∑ p ∈ J, min (distF s p) (capC s) - corrC cstF s ≤ + ∑ r ∈ R, ∑ i ∈ range (nR r), c2 (gs s) (lev dR r i) (lev dR r (i + 1)) + Omega ks mr s) + (hdist : ∀ s, 9 / 10 ≤ s → s ≤ 1 - ((tN0 : ℚ) : ℝ) → ∀ p ∈ J, spF (1 - s) ≤ distF s p) + (hJ : 96 ≤ J.card) + (hspMono : MonotoneOn spF (Set.Icc ((tN0 : ℚ) : ℝ) (1 / 10))) + (hcstMono : MonotoneOn cstF (Set.Icc ((tN0 : ℚ) : ℝ) (1 / 10))) + (hspTabN : ((spFloN0 : ℚ) : ℝ) ≤ spF ((tN0 : ℚ) : ℝ) ∧ ((spFloN1 : ℚ) : ℝ) ≤ spF ((tN1 : ℚ) : ℝ) ∧ + ((spFloN2 : ℚ) : ℝ) ≤ spF ((tN2 : ℚ) : ℝ) ∧ ((spFloN3 : ℚ) : ℝ) ≤ spF ((tN3 : ℚ) : ℝ) ∧ + ((spFloN4 : ℚ) : ℝ) ≤ spF ((tN4 : ℚ) : ℝ)) + (hcstTabN : cstF ((tN1 : ℚ) : ℝ) ≤ ((cHN0 : ℚ) : ℝ) ∧ cstF ((tN2 : ℚ) : ℝ) ≤ ((cHN1 : ℚ) : ℝ) ∧ + cstF ((tN3 : ℚ) : ℝ) ≤ ((cHN2 : ℚ) : ℝ) ∧ cstF ((tN4 : ℚ) : ℝ) ≤ ((cHN3 : ℚ) : ℝ) ∧ + cstF ((tN5 : ℚ) : ℝ) ≤ ((cHN4 : ℚ) : ℝ)) : + ∀ t : ℝ, ((tN0 : ℚ) : ℝ) ≤ t → t ≤ 1 → Finv (1 - t) (invoice (caller 6 7) n 17) < 0 := by + have piece : ∀ (a b lcp σ : ℚ), sigOK (1 - b) (1 - a) σ = true → 0 ≤ σ → tN0 ≤ a → a ≤ b → b ≤ 1 / 10 → + (∀ s : ℝ, ((1 - b : ℚ) : ℝ) ≤ s → s ≤ ((1 - a : ℚ) : ℝ) → (lcp : ℝ) ≤ 96 * ellC spF s - corrC cstF s ∧ 0 ≤ ellC spF s) → + (∀ s : ℝ, ((1 - b : ℚ) : ℝ) ≤ s → s ≤ ((1 - a : ℚ) : ℝ) → Fc cfC s < 17 * (((lcp - 5 * σ : ℚ)) : ℝ)) → + ∀ t : ℝ, (a : ℝ) ≤ t → t ≤ (b : ℝ) → Finv (1 - t) (invoice (caller 6 7) n 17) < 0 := by + intro a b lcp σ hσc hσ0 ha0 hab hb hLcp hFb t h1 h2 + have ha0q : (0 : ℚ) ≤ a := le_trans (by unfold tN0; norm_num) ha0 + have ha0' : ((tN0 : ℚ) : ℝ) ≤ a := by exact_mod_cast ha0 + have hb' : (b : ℝ) ≤ 1 / 10 := by + have := (Rat.cast_le (K := ℝ)).mpr hb + push_cast at this; exact this + have hab' : (a : ℝ) ≤ b := by exact_mod_cast hab + have hA0 : (0 : ℝ) ≤ a := by exact_mod_cast ha0q + have hs0 : 0 ≤ 1 - t := by linarith + have hs1 : 1 - t ≤ 1 := by linarith + have hσ : ∀ a' b' : ℕ, 1 ≤ a' → a' ≤ b' → b' ≤ 8 → c2 (gs (1 - t)) (a' : ℝ) (b' : ℝ) ≤ (σ : ℝ) := by + intro a' b' h1' h2' h3' + exact sig_of_ok (1 - b) (1 - a) σ hσc (by linarith) (by linarith) hσ0 (1 - t) + (by push_cast; linarith) (by push_cast; linarith) a' b' h1' h2' h3' + have hLcp' := hLcp (1 - t) (by push_cast; linarith) (by push_cast; linarith) + have hslo : (9 / 10 : ℝ) ≤ 1 - t := by linarith + have hshi : 1 - t ≤ 1 - ((tN0 : ℚ) : ℝ) := by linarith + have hell : 0 ≤ ellC spF (1 - t) := hLcp'.2 + have hE := E_lower_cap_omN R nR dR J (distF (1 - t)) (E (1 - t)) (1 - t) (capC (1 - t)) (corrC cstF (1 - t)) (ellC spF (1 - t)) + (σ : ℝ) (Omega ks mr (1 - t)) 5 96 hmono hd9 hmix (by exact_mod_cast hσ0) hσ (hcong (1 - t) hslo hshi) (hEex _ hs0 hs1) + (fun p hp => le_min (le_trans (min_le_left _ _) (hdist (1 - t) hslo hshi p hp)) (min_le_right _ _)) hJ hell + have hE' : (((lcp - 5 * σ : ℚ)) : ℝ) ≤ E (1 - t) + Omega ks mr (1 - t) := by + push_cast; push_cast at hE; linarith [hLcp'.1] + exact branchC_om n ks mr (E (1 - t)) _ (1 - t) (hF _ hs0 hs1) hE' + (hFb (1 - t) (by push_cast; linarith) (by push_cast; linarith)) + intro t ht ht1 + have ht0 : (0 : ℝ) ≤ ((tN0 : ℚ) : ℝ) := by unfold tN0; norm_num + have hs0 : (0 : ℝ) ≤ 1 - t := by linarith + have hs1 : 1 - t ≤ 1 := by linarith + have hu1 : (1 : ℝ) ≤ (2 : ℝ) ^ (1 - t) := Real.one_le_rpow (by norm_num) hs0 + have hu2 : (2 : ℝ) ^ (1 - t) ≤ 2 := by + have := Real.rpow_le_rpow_of_exponent_le (show (1 : ℝ) ≤ 2 by norm_num) hs1; simpa using this + have hE0 : 0 ≤ E (1 - t) := + le_trans (mul_nonneg (by linarith) (Nat.cast_nonneg st)) (hst _ hs0 hs1) + rcases le_or_gt (1 / 10 : ℝ) t with h10 | h10 + · have h2 := invoice_F (1 - t) (caller 6 7) n 17 + have h3 := invoice_F (1 - t) (caller 6 7) natBaseC 17 + have h4 := natBaseC_F (1 - t) + push_cast at h2 h3 + have h1 := own56_floor (1 - t) hs0 hs1 ks hk hmass hmd mr st hmr (Finv (1 - t) n) (E (1 - t)) 0 (hF _ hs0 hs1) hY + (hst _ hs0 hs1) hE0 + have hc0 : (0 : ℝ) ≤ 88 * (2 - (2 : ℝ) ^ (1 - t)) := by linarith + rw [max_eq_left hc0] at h1 + have h5 := cfC88_neg (1 - t) hs0 (by linarith) + have h6 := base88_eq (1 - t) + nlinarith + · obtain ⟨sp0, sp1, sp2, sp3, sp4⟩ := hspTabN + obtain ⟨cs0, cs1, cs2, cs3, cs4⟩ := hcstTabN + have q01 : tN0 ≤ tN1 := by unfold tN0 tN1; norm_num + have q12 : tN1 ≤ tN2 := by unfold tN1 tN2; norm_num + have q23 : tN2 ≤ tN3 := by unfold tN2 tN3; norm_num + have q34 : tN3 ≤ tN4 := by unfold tN3 tN4; norm_num + have q45 : tN4 ≤ tN5 := by unfold tN4 tN5; norm_num + have b1 : tN1 ≤ 1 / 10 := by unfold tN1; norm_num + have b2 : tN2 ≤ 1 / 10 := by unfold tN2; norm_num + have b3 : tN3 ≤ 1 / 10 := by unfold tN3; norm_num + have b4 : tN4 ≤ 1 / 10 := by unfold tN4; norm_num + have b5 : tN5 ≤ 1 / 10 := by unfold tN5; norm_num + have q02 := le_trans q01 q12 + have q03 := le_trans q02 q23 + have q04 := le_trans q03 q34 + have un0 := unit_of_Fup tN1 unitLoN0 (by unfold tN1; norm_num) (by unfold tN1; norm_num) unitN0 + have un1 := unit_of_Fup tN2 unitLoN1 (by unfold tN2; norm_num) (by unfold tN2; norm_num) unitN1 + have un2 := unit_of_Fup tN3 unitLoN2 (by unfold tN3; norm_num) (by unfold tN3; norm_num) unitN2 + have un3 := unit_of_Fup tN4 unitLoN3 (by unfold tN4; norm_num) (by unfold tN4; norm_num) unitN3 + have un4 := unit_of_Fup tN5 unitLoN4 (by unfold tN5; norm_num) (by unfold tN5; norm_num) unitN4 + have zspFloN0 : (0 : ℚ) ≤ spFloN0 := by unfold spFloN0; norm_num + have zspFloN1 : (0 : ℚ) ≤ spFloN1 := by unfold spFloN1; norm_num + have zspFloN2 : (0 : ℚ) ≤ spFloN2 := by unfold spFloN2; norm_num + have zspFloN3 : (0 : ℚ) ≤ spFloN3 := by unfold spFloN3; norm_num + have zspFloN4 : (0 : ℚ) ≤ spFloN4 := by unfold spFloN4; norm_num + have zcHN0 : (0 : ℚ) ≤ cHN0 := by unfold cHN0; norm_num + have zcHN1 : (0 : ℚ) ≤ cHN1 := by unfold cHN1; norm_num + have zcHN2 : (0 : ℚ) ≤ cHN2 := by unfold cHN2; norm_num + have zcHN3 : (0 : ℚ) ≤ cHN3 := by unfold cHN3; norm_num + have zcHN4 : (0 : ℚ) ≤ cHN4 := by unfold cHN4; norm_num + have zunitLoN0 : (0 : ℚ) ≤ unitLoN0 := by unfold unitLoN0; norm_num + have zunitLoN1 : (0 : ℚ) ≤ unitLoN1 := by unfold unitLoN1; norm_num + have zunitLoN2 : (0 : ℚ) ≤ unitLoN2 := by unfold unitLoN2; norm_num + have zunitLoN3 : (0 : ℚ) ≤ unitLoN3 := by unfold unitLoN3; norm_num + have zunitLoN4 : (0 : ℚ) ≤ unitLoN4 := by unfold unitLoN4; norm_num + have hF4 : ∀ (a b L : ℚ), 93 / 100 ≤ 1 - b → a ≤ b → tN0 ≤ a → Fup cfC (1 - a) (1 - a) < 17 * L → + ∀ s : ℝ, ((1 - b : ℚ) : ℝ) ≤ s → s ≤ ((1 - a : ℚ) : ℝ) → Fc cfC s < 17 * (L : ℝ) := by + intro a b L hb93 hab haN hpt + exact hFbJ_of a b L hb93 hab (le_trans (by unfold tJ0 tN0; norm_num) haN) hpt + by_cases k1 : t ≤ ((tN1 : ℚ) : ℝ) + · exact piece tN0 tN1 lcpN0 sgN0 sigN0 (by unfold sgN0; norm_num) (le_refl _) q01 b1 + (tab_pieceN spF cstF tN0 tN1 lcpN0 cHN0 spFloN0 unitLoN0 zcHN0 zspFloN0 zunitLoN0 (le_refl _) q01 b1 + hspMono hcstMono sp0 cs0 un0 tabN0.1 tabN0.2) + (hF4 tN0 tN1 LN0 (by unfold tN1; norm_num) q01 (le_refl _) ptN0) t ht k1 + by_cases k2 : t ≤ ((tN2 : ℚ) : ℝ) + · exact piece tN1 tN2 lcpN1 sgN1 sigN1 (by unfold sgN1; norm_num) q01 q12 b2 + (tab_pieceN spF cstF tN1 tN2 lcpN1 cHN1 spFloN1 unitLoN1 zcHN1 zspFloN1 zunitLoN1 q01 q12 b2 + hspMono hcstMono sp1 cs1 un1 tabN1.1 tabN1.2) + (hF4 tN1 tN2 LN1 (by unfold tN2; norm_num) q12 q01 ptN1) t (by push Not at k1; exact k1.le) k2 + by_cases k3 : t ≤ ((tN3 : ℚ) : ℝ) + · exact piece tN2 tN3 lcpN2 sgN2 sigN2 (by unfold sgN2; norm_num) q02 q23 b3 + (tab_pieceN spF cstF tN2 tN3 lcpN2 cHN2 spFloN2 unitLoN2 zcHN2 zspFloN2 zunitLoN2 q02 q23 b3 + hspMono hcstMono sp2 cs2 un2 tabN2.1 tabN2.2) + (hF4 tN2 tN3 LN2 (by unfold tN3; norm_num) q23 q02 ptN2) t (by push Not at k2; exact k2.le) k3 + by_cases k4 : t ≤ ((tN4 : ℚ) : ℝ) + · exact piece tN3 tN4 lcpN3 sgN3 sigN3 (by unfold sgN3; norm_num) q03 q34 b4 + (tab_pieceN spF cstF tN3 tN4 lcpN3 cHN3 spFloN3 unitLoN3 zcHN3 zspFloN3 zunitLoN3 q03 q34 b4 + hspMono hcstMono sp3 cs3 un3 tabN3.1 tabN3.2) + (hF4 tN3 tN4 LN3 (by unfold tN4; norm_num) q34 q03 ptN3) t (by push Not at k3; exact k3.le) k4 + · refine piece tN4 tN5 lcpN4 sgN4 sigN4 (by unfold sgN4; norm_num) q04 q45 b5 + (tab_pieceN spF cstF tN4 tN5 lcpN4 cHN4 spFloN4 unitLoN4 zcHN4 zspFloN4 zunitLoN4 q04 q45 b5 + hspMono hcstMono sp4 cs4 un4 tabN4.1 tabN4.2) ?_ t (by push Not at k4; exact k4.le) (by unfold tN5; push_cast; exact h10.le) + intro s hs1' hs2' + have e1 : (((1 - tN5 : ℚ)) : ℝ) = 9 / 10 := by unfold tN5; norm_num + have e2 : (((1 - tN4 : ℚ)) : ℝ) = 93 / 100 := by unfold tN4; norm_num + rw [e1] at hs1'; rw [e2] at hs2' + have hq : (((17 * LN4 : ℚ)) : ℝ) = 17 * (((lcpN4 - 5 * sgN4 : ℚ)) : ℝ) := by unfold LN4; push_cast; ring + by_cases hm : s ≤ 915 / 1000 + · have := Fc_le cfC cfC_ok (9 / 10) (915 / 1000) (by norm_num) (by norm_num) s (by push_cast; exact hs1') (by push_cast; exact hm) + have h2 : ((Fup cfC (9 / 10) (915 / 1000) : ℚ) : ℝ) < (((17 * LN4 : ℚ)) : ℝ) := by exact_mod_cast boxN4a + linarith + · push Not at hm + have := Fc_le cfC cfC_ok (915 / 1000) (93 / 100) (by norm_num) (by norm_num) s (by push_cast; exact hm.le) (by push_cast; exact hs2') + have h2 : ((Fup cfC (915 / 1000) (93 / 100) : ℚ) : ℝ) < (((17 * LN4 : ℚ)) : ℝ) := by exact_mod_cast boxN4b + linarith + +end CongestionNative + +#print axioms CongestionNative.tab_pieceN +#print axioms CongestionNative.ceiling_native_N96 diff --git a/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeNDefs.lean b/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeNDefs.lean new file mode 100644 index 0000000000..b6aae07eee --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeNDefs.lean @@ -0,0 +1,55 @@ +import Mathlib.Data.Rat.Defs +import Mathlib.Tactic.NormNum + +/-! CONGESTION-NATIVE-N96 tables. Source: internal table generators (N = 96; +spF_lo / unit_lo rounded DOWN to 14 digits, cst rounded UP, outward Decimal 80 digits). -/ +namespace CongestionNative + +def tN0 : ℚ := 151027 / 10 ^ 7 +def tN1 : ℚ := 151077 / 10 ^ 7 +def tN2 : ℚ := 153077 / 10 ^ 7 +def tN3 : ℚ := 253077 / 10 ^ 7 +def tN4 : ℚ := 7 / 100 +def tN5 : ℚ := 1 / 10 +def sgN0 : ℚ := 61897 / 1000000 +def cHN0 : ℚ := 23253 / 625000 +def lcpN0 : ℚ := 198661 / 500000 +def LN0 : ℚ := lcpN0 - 5 * sgN0 +def spFloN0 : ℚ := 723917880571 / 100000000000000 +def unitLoN0 : ℚ := 47678349095889 / 50000000000000 +def sgN1 : ℚ := 4031 / 62500 +def cHN1 : ℚ := 188447 / 5000000 +def lcpN1 : ℚ := 393673 / 1000000 +def LN1 : ℚ := lcpN1 - 5 * sgN1 +def spFloN1 : ℚ := 362077327347 / 50000000000000 +def unitLoN1 : ℚ := 23824137184247 / 25000000000000 +def sgN2 : ℚ := 40937 / 200000 +def cHN2 : ℚ := 77077 / 1250000 +def lcpN2 : ℚ := 105493 / 500000 +def LN2 : ℚ := lcpN2 - 5 * sgN2 +def spFloN2 : ℚ := 45851503937 / 6250000000000 +def unitLoN2 : ℚ := 23083018215939 / 25000000000000 +def sgN3 : ℚ := 747329 / 1000000 +def cHN3 : ℚ := 1628077 / 10000000 +def lcpN3 : ℚ := -147349 / 1000000 +def LN3 : ℚ := lcpN3 - 5 * sgN3 +def spFloN3 : ℚ := 1203242422603 / 100000000000000 +def unitLoN3 : ℚ := 5004058989633 / 6250000000000 +def sgN4 : ℚ := 24423 / 40000 +def cHN4 : ℚ := 2255027 / 10000000 +def lcpN4 : ℚ := -43839 / 125000 +def LN4 : ℚ := lcpN4 - 5 * sgN4 +def spFloN4 : ℚ := 3212352863571 / 100000000000000 +def unitLoN4 : ℚ := 72665488499219 / 100000000000000 +theorem tabN0 : lcpN0 + 8 * cHN0 ≤ 96 * spFloN0 ∧ lcpN0 + 8 * cHN0 ≤ 96 * (unitLoN0 / 48) := by + unfold lcpN0 cHN0 spFloN0 unitLoN0; constructor <;> norm_num +theorem tabN1 : lcpN1 + 8 * cHN1 ≤ 96 * spFloN1 ∧ lcpN1 + 8 * cHN1 ≤ 96 * (unitLoN1 / 48) := by + unfold lcpN1 cHN1 spFloN1 unitLoN1; constructor <;> norm_num +theorem tabN2 : lcpN2 + 8 * cHN2 ≤ 96 * spFloN2 ∧ lcpN2 + 8 * cHN2 ≤ 96 * (unitLoN2 / 48) := by + unfold lcpN2 cHN2 spFloN2 unitLoN2; constructor <;> norm_num +theorem tabN3 : lcpN3 + 8 * cHN3 ≤ 96 * spFloN3 ∧ lcpN3 + 8 * cHN3 ≤ 96 * (unitLoN3 / 48) := by + unfold lcpN3 cHN3 spFloN3 unitLoN3; constructor <;> norm_num +theorem tabN4 : lcpN4 + 8 * cHN4 ≤ 96 * spFloN4 ∧ lcpN4 + 8 * cHN4 ≤ 96 * (unitLoN4 / 48) := by + unfold lcpN4 cHN4 spFloN4 unitLoN4; constructor <;> norm_num + +end CongestionNative diff --git a/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeNPt.lean b/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeNPt.lean new file mode 100644 index 0000000000..98fa6fc399 --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeNPt.lean @@ -0,0 +1,14 @@ +import Nov15.CongestionI3DualConst +import Nov15.CongestionI3NumC1 +import Nov15.CongestionNativeJUnit +import Nov15.CongestionNativeNDefs +namespace CongestionNative +open NumCertK CongestionI3 CongestionI3Dual +theorem cfC_dN : 0 < dLo cfC (93 / 100) (1 - tN0) := by unfold tN0; decide +kernel +theorem ptN0 : Fup cfC (1 - tN0) (1 - tN0) < 17 * LN0 := by unfold tN0 LN0 lcpN0 sgN0; decide +kernel +theorem ptN1 : Fup cfC (1 - tN1) (1 - tN1) < 17 * LN1 := by unfold tN1 LN1 lcpN1 sgN1; decide +kernel +theorem ptN2 : Fup cfC (1 - tN2) (1 - tN2) < 17 * LN2 := by unfold tN2 LN2 lcpN2 sgN2; decide +kernel +theorem ptN3 : Fup cfC (1 - tN3) (1 - tN3) < 17 * LN3 := by unfold tN3 LN3 lcpN3 sgN3; decide +kernel +theorem boxN4a : Fup cfC (9 / 10) (915 / 1000) < 17 * LN4 := by unfold LN4 lcpN4 sgN4; decide +kernel +theorem boxN4b : Fup cfC (915 / 1000) (93 / 100) < 17 * LN4 := by unfold LN4 lcpN4 sgN4; decide +kernel +end CongestionNative diff --git a/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeNSig0.lean b/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeNSig0.lean new file mode 100644 index 0000000000..f705c5aea7 --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeNSig0.lean @@ -0,0 +1,7 @@ +import Nov15.CongestionI3DualSig +import Nov15.CongestionI3NumC1 +import Nov15.CongestionNativeNDefs +namespace CongestionNative +open NumCertK CongestionI3 CongestionI3Dual +theorem sigN0 : sigOK (1 - tN1) (1 - tN0) sgN0 = true := by unfold tN0 tN1 sgN0; decide +kernel +end CongestionNative diff --git a/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeNSig1.lean b/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeNSig1.lean new file mode 100644 index 0000000000..ef865b188c --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeNSig1.lean @@ -0,0 +1,7 @@ +import Nov15.CongestionI3DualSig +import Nov15.CongestionI3NumC1 +import Nov15.CongestionNativeNDefs +namespace CongestionNative +open NumCertK CongestionI3 CongestionI3Dual +theorem sigN1 : sigOK (1 - tN2) (1 - tN1) sgN1 = true := by unfold tN1 tN2 sgN1; decide +kernel +end CongestionNative diff --git a/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeNSig2.lean b/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeNSig2.lean new file mode 100644 index 0000000000..d681ca8803 --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeNSig2.lean @@ -0,0 +1,7 @@ +import Nov15.CongestionI3DualSig +import Nov15.CongestionI3NumC1 +import Nov15.CongestionNativeNDefs +namespace CongestionNative +open NumCertK CongestionI3 CongestionI3Dual +theorem sigN2 : sigOK (1 - tN3) (1 - tN2) sgN2 = true := by unfold tN2 tN3 sgN2; decide +kernel +end CongestionNative diff --git a/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeNSig3.lean b/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeNSig3.lean new file mode 100644 index 0000000000..8e7a02f79b --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeNSig3.lean @@ -0,0 +1,7 @@ +import Nov15.CongestionI3DualSig +import Nov15.CongestionI3NumC1 +import Nov15.CongestionNativeNDefs +namespace CongestionNative +open NumCertK CongestionI3 CongestionI3Dual +theorem sigN3 : sigOK (1 - tN4) (1 - tN3) sgN3 = true := by unfold tN3 tN4 sgN3; decide +kernel +end CongestionNative diff --git a/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeNSig4.lean b/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeNSig4.lean new file mode 100644 index 0000000000..5f70520543 --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeNSig4.lean @@ -0,0 +1,7 @@ +import Nov15.CongestionI3DualSig +import Nov15.CongestionI3NumC1 +import Nov15.CongestionNativeNDefs +namespace CongestionNative +open NumCertK CongestionI3 CongestionI3Dual +theorem sigN4 : sigOK (1 - tN5) (1 - tN4) sgN4 = true := by unfold tN4 tN5 sgN4; decide +kernel +end CongestionNative diff --git a/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeNUnit.lean b/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeNUnit.lean new file mode 100644 index 0000000000..63d71ddb17 --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeNUnit.lean @@ -0,0 +1,10 @@ +import Nov15.CongestionNativeJUnit +import Nov15.CongestionNativeNDefs +namespace CongestionNative +open NumCertK CongestionI3 CongestionI3Dual +theorem unitN0 : Fup unitCF (1 - tN1) (1 - tN1) < -unitLoN0 := by unfold tN1 unitLoN0; decide +kernel +theorem unitN1 : Fup unitCF (1 - tN2) (1 - tN2) < -unitLoN1 := by unfold tN2 unitLoN1; decide +kernel +theorem unitN2 : Fup unitCF (1 - tN3) (1 - tN3) < -unitLoN2 := by unfold tN3 unitLoN2; decide +kernel +theorem unitN3 : Fup unitCF (1 - tN4) (1 - tN4) < -unitLoN3 := by unfold tN4 unitLoN3; decide +kernel +theorem unitN4 : Fup unitCF (1 - tN5) (1 - tN5) < -unitLoN4 := by unfold tN5 unitLoN4; decide +kernel +end CongestionNative diff --git a/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeTab.lean b/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeTab.lean new file mode 100644 index 0000000000..bb00941798 --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeTab.lean @@ -0,0 +1,38 @@ +import Mathlib.Data.Rat.Defs +import Mathlib.Tactic.NormNum +import Nov15.CongestionI3DualConst + +/-! CONGESTION-NATIVE certified rational tables. +Source: internal notes (Decimal exp/ln at 80 digits, +-1e-70 brackets; every weight of the spF DAG rounded DOWN, +cst rounded UP, unit_lo = 9^s lower - 8^s upper). The values below were emitted by re-running hc9's `spF_lo` / `unit_lo` and converting the +80-digit Decimals to exact rationals, rounded DOWN to 14 digits (outward). `cHC_j` are hc9's own rounded-UP cst brackets. +Here only the pure arithmetic is proved (kernel, norm_num): lcpC_j + 8 cHC_j <= 1936 * min(spFloC_j, unitLoC_j / 48). +The statements `spFloC_j <= spF(tC_j)`, `cst(t_{j+1}) <= cHC_j`, `unitLoC_j <= 9^s - 8^s` are HYPOTHESES of the ceiling (computed, hc9.log). -/ +namespace CongestionNative +open CongestionI3Dual + +def spFloC0 : ℚ := 131069767447 / 20000000000000 +def spFloC1 : ℚ := 655443767027 / 100000000000000 +def spFloC2 : ℚ := 26407594739 / 4000000000000 +def spFloC3 : ℚ := 141372084217 / 12500000000000 +/-- lower bound of 9^(1-t_{j+1}) - 8^(1-t_{j+1}) (t_1, t_2, t_3, 1/10) -/ +def unitLoC0 : ℚ := 11974198659989 / 12500000000000 +def unitLoC1 : ℚ := 95763386760327 / 100000000000000 +def unitLoC2 : ℚ := 23196470570391 / 25000000000000 +def unitLoC3 : ℚ := 72665488499219 / 100000000000000 +/-- upper brackets of cst(t_{j+1}) -/ +def cHC0 : ℚ := 84217 / 2500000 +def cHC1 : ℚ := 339299 / 10 ^ 7 +def cHC2 : ℚ := 579807 / 10 ^ 7 +def cHC3 : ℚ := 2255027 / 10 ^ 7 + +theorem tabC0 : lcpC0 + 8 * cHC0 ≤ 1936 * spFloC0 ∧ lcpC0 + 8 * cHC0 ≤ 1936 * (unitLoC0 / 48) := by + unfold lcpC0 cHC0 spFloC0 unitLoC0; constructor <;> norm_num +theorem tabC1 : lcpC1 + 8 * cHC1 ≤ 1936 * spFloC1 ∧ lcpC1 + 8 * cHC1 ≤ 1936 * (unitLoC1 / 48) := by + unfold lcpC1 cHC1 spFloC1 unitLoC1; constructor <;> norm_num +theorem tabC2 : lcpC2 + 8 * cHC2 ≤ 1936 * spFloC2 ∧ lcpC2 + 8 * cHC2 ≤ 1936 * (unitLoC2 / 48) := by + unfold lcpC2 cHC2 spFloC2 unitLoC2; constructor <;> norm_num +theorem tabC3 : lcpC3 + 8 * cHC3 ≤ 1936 * spFloC3 ∧ lcpC3 + 8 * cHC3 ≤ 1936 * (unitLoC3 / 48) := by + unfold lcpC3 cHC3 spFloC3 unitLoC3; constructor <;> norm_num + +end CongestionNative diff --git a/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeZ.lean b/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeZ.lean new file mode 100644 index 0000000000..a4c6fab26c --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeZ.lean @@ -0,0 +1,212 @@ +import Nov15.CongestionNativeJ +import Nov15.CongestionNativeZDefs +import Nov15.CongestionNativeZSig0 +import Nov15.CongestionNativeZSig1 +import Nov15.CongestionNativeZSig2 +import Nov15.CongestionNativeZSig3 +import Nov15.CongestionNativeZSig4 +import Nov15.CongestionNativeZPt +import Nov15.CongestionNativeZUnit + +/-! +CONGESTION-NATIVE-Z0: `ceiling_native` / `ceiling_native_J` with the junk count hypothesis DROPPED (`hJ : 0 <= |J|` is trivial): the J-free ceiling: no junk-count assumption and no upper bound on owned mass (it keeps `hmass : 56 <= ks.sum`, `hk`, `hmd`, `hmr`, `hY` and the rest of class K). Conclusion: F(1 - t, invoice (caller 6 7) n 17) < 0 for t in [tZ0, 1], +tZ0 = .0151869, i.e. kappa <= .0151869 (own56, m <= 5) for every word satisfying the hypotheses (see JunkLawA.md). +Pieces: [tZ0, tZ1, tZ2, tZ3, .07, .1] (4 point-form pieces with F_base monotone on [.93, 1 - tZ0], one box-form piece on s in [.9, .93]), then t >= .1 as in `ceiling_native`. +Hypotheses are those of `ceiling_native_J` with the hJ line removed and the new endpoint brackets (hspTabN, hcstTabN); all unit brackets, sigma certificates, F_base enclosures are kernel. +-/ +namespace CongestionNative +open NumCertK JointCeiling CallerCost CongestionI3 CongestionI3Dual Finset + +/-- one t-piece `[a, b]` with N = 0; `lcp` may be negative (only `0 <= spLo`, `0 <= unLo` are needed for `0 <= ell`). -/ +theorem tab_pieceZ (spF cstF : ℝ → ℝ) (a b : ℚ) (lcp cH spLo unLo : ℚ) (hcH : 0 ≤ cH) (hsp0 : 0 ≤ spLo) (hun0 : 0 ≤ unLo) + (ha0 : tZ0 ≤ a) (hab : a ≤ b) (hb : b ≤ 1 / 10) + (hmS : MonotoneOn spF (Set.Icc ((tZ0 : ℚ) : ℝ) (1 / 10))) (hmC : MonotoneOn cstF (Set.Icc ((tZ0 : ℚ) : ℝ) (1 / 10))) + (hsp : (spLo : ℝ) ≤ spF (a : ℝ)) (hcs : cstF (b : ℝ) ≤ cH) + (hun : (unLo : ℝ) ≤ (9 : ℝ) ^ (1 - (b : ℝ)) - (8 : ℝ) ^ (1 - (b : ℝ))) + (hn1 : lcp + 8 * cH ≤ 0 * spLo) (hn2 : lcp + 8 * cH ≤ 0 * (unLo / 48)) : + ∀ s : ℝ, ((1 - b : ℚ) : ℝ) ≤ s → s ≤ ((1 - a : ℚ) : ℝ) → (lcp : ℝ) ≤ 0 * ellC spF s - corrC cstF s ∧ 0 ≤ ellC spF s := by + intro s h1 h2 + push_cast at h1 h2 + have ha' : ((tZ0 : ℚ) : ℝ) ≤ a := by exact_mod_cast ha0 + have hab' : (a : ℝ) ≤ b := by exact_mod_cast hab + have hb' : (b : ℝ) ≤ 1 / 10 := by + have := (Rat.cast_le (K := ℝ)).mpr hb + push_cast at this; exact this + have htl : (a : ℝ) ≤ 1 - s := by linarith + have htu : 1 - s ≤ (b : ℝ) := by linarith + have hspt : spF a ≤ spF (1 - s) := hmS ⟨ha', by linarith⟩ ⟨by linarith, by linarith⟩ htl + have hcst : cstF (1 - s) ≤ cstF b := hmC ⟨by linarith, by linarith⟩ ⟨by linarith, hb'⟩ htu + have hcap : (unLo : ℝ) / 48 ≤ capC s := by + have := unit_mono (1 - b) s (by linarith) h1 + unfold capC; linarith + have hell : min (spLo : ℝ) ((unLo : ℝ) / 48) ≤ ellC spF s := by + unfold ellC + exact le_min (le_trans (min_le_left _ _) (by linarith)) (le_trans (min_le_right _ _) hcap) + have hcorr : corrC cstF s ≤ 8 * (cH : ℝ) := by unfold corrC; linarith + have hn1' : (lcp : ℝ) + 8 * cH ≤ 0 * spLo := by exact_mod_cast hn1 + have hn2' : (lcp : ℝ) + 8 * cH ≤ 0 * ((unLo : ℝ) / 48) := by exact_mod_cast hn2 + have hs0' : (0 : ℝ) ≤ spLo := by exact_mod_cast hsp0 + have hu0' : (0 : ℝ) ≤ (unLo : ℝ) / 48 := by + have h : (0 : ℝ) ≤ unLo := by exact_mod_cast hun0 + linarith + have hc0 : (0 : ℝ) ≤ cH := by exact_mod_cast hcH + have hmin0 : (0 : ℝ) ≤ min (spLo : ℝ) ((unLo : ℝ) / 48) := le_min hs0' hu0' + rcases le_total (spLo : ℝ) ((unLo : ℝ) / 48) with hh | hh + · rw [min_eq_left hh] at hell hmin0; exact ⟨by linarith, by linarith⟩ + · rw [min_eq_right hh] at hell hmin0; exact ⟨by linarith, by linarith⟩ + +/-- **J-free ceiling (N = 0).** Same statement as `ceiling_native_J` with no junk-count hypothesis (N = 0), hcong*/hdist on s in [.9, 1 - tZ0], monotonicity on [tZ0, 1/10], five spF and five cst endpoint brackets. +Conclusion on t in [tZ0, 1]: kappa <= .0151869. -/ +theorem ceiling_native_Z0 {ι : Type*} [DecidableEq ι] + (R : Finset ι) (nR : ι → ℕ) (dR : ι → ℕ → ℕ) + (hmono : ∀ r ∈ R, ∀ i < nR r, dR r i ≤ dR r (i + 1)) (hd9 : ∀ r ∈ R, dR r (nR r) ≤ 9) + (hmix : (R.filter fun r => Mixed dR nR r).card ≤ 5) + (n : Inv) (ks : List ℕ) (mr st : ℕ) (E : ℝ → ℝ) (J : Finset (ℕ × ℕ)) (distF : ℝ → ℕ × ℕ → ℝ) (spF cstF : ℝ → ℝ) + (hk : ∀ k ∈ ks, 1 ≤ k ∧ k ≤ 9) (hmass : 56 ≤ ks.sum) (hmd : 8 ≤ ks.length) (hmr : 8 ≤ mr) + (hF : ∀ s, 0 ≤ s → s ≤ 1 → Finv s n ≤ -400 * (8 : ℝ) ^ s - dprice ks s - mr - E s) + (hY : 104 ≤ st + (ks.length + mr)) + (hst : ∀ s, 0 ≤ s → s ≤ 1 → (2 - (2 : ℝ) ^ s) * st ≤ E s) + (hEex : ∀ s, 0 ≤ s → s ≤ 1 → ∑ r ∈ R, ex (gs s) (lev dR r) (nR r) ≤ E s) + (hcong : ∀ s, 9 / 10 ≤ s → s ≤ 1 - ((tZ0 : ℚ) : ℝ) → + ∑ p ∈ J, min (distF s p) (capC s) - corrC cstF s ≤ + ∑ r ∈ R, ∑ i ∈ range (nR r), c2 (gs s) (lev dR r i) (lev dR r (i + 1)) + Omega ks mr s) + (hdist : ∀ s, 9 / 10 ≤ s → s ≤ 1 - ((tZ0 : ℚ) : ℝ) → ∀ p ∈ J, spF (1 - s) ≤ distF s p) + (hspMono : MonotoneOn spF (Set.Icc ((tZ0 : ℚ) : ℝ) (1 / 10))) + (hcstMono : MonotoneOn cstF (Set.Icc ((tZ0 : ℚ) : ℝ) (1 / 10))) + (hspTabN : ((spFloZ0 : ℚ) : ℝ) ≤ spF ((tZ0 : ℚ) : ℝ) ∧ ((spFloZ1 : ℚ) : ℝ) ≤ spF ((tZ1 : ℚ) : ℝ) ∧ + ((spFloZ2 : ℚ) : ℝ) ≤ spF ((tZ2 : ℚ) : ℝ) ∧ ((spFloZ3 : ℚ) : ℝ) ≤ spF ((tZ3 : ℚ) : ℝ) ∧ + ((spFloZ4 : ℚ) : ℝ) ≤ spF ((tZ4 : ℚ) : ℝ)) + (hcstTabN : cstF ((tZ1 : ℚ) : ℝ) ≤ ((cHZ0 : ℚ) : ℝ) ∧ cstF ((tZ2 : ℚ) : ℝ) ≤ ((cHZ1 : ℚ) : ℝ) ∧ + cstF ((tZ3 : ℚ) : ℝ) ≤ ((cHZ2 : ℚ) : ℝ) ∧ cstF ((tZ4 : ℚ) : ℝ) ≤ ((cHZ3 : ℚ) : ℝ) ∧ + cstF ((tZ5 : ℚ) : ℝ) ≤ ((cHZ4 : ℚ) : ℝ)) : + ∀ t : ℝ, ((tZ0 : ℚ) : ℝ) ≤ t → t ≤ 1 → Finv (1 - t) (invoice (caller 6 7) n 17) < 0 := by + have piece : ∀ (a b lcp σ : ℚ), sigOK (1 - b) (1 - a) σ = true → 0 ≤ σ → tZ0 ≤ a → a ≤ b → b ≤ 1 / 10 → + (∀ s : ℝ, ((1 - b : ℚ) : ℝ) ≤ s → s ≤ ((1 - a : ℚ) : ℝ) → (lcp : ℝ) ≤ 0 * ellC spF s - corrC cstF s ∧ 0 ≤ ellC spF s) → + (∀ s : ℝ, ((1 - b : ℚ) : ℝ) ≤ s → s ≤ ((1 - a : ℚ) : ℝ) → Fc cfC s < 17 * (((lcp - 5 * σ : ℚ)) : ℝ)) → + ∀ t : ℝ, (a : ℝ) ≤ t → t ≤ (b : ℝ) → Finv (1 - t) (invoice (caller 6 7) n 17) < 0 := by + intro a b lcp σ hσc hσ0 ha0 hab hb hLcp hFb t h1 h2 + have ha0q : (0 : ℚ) ≤ a := le_trans (by unfold tZ0; norm_num) ha0 + have ha0' : ((tZ0 : ℚ) : ℝ) ≤ a := by exact_mod_cast ha0 + have hb' : (b : ℝ) ≤ 1 / 10 := by + have := (Rat.cast_le (K := ℝ)).mpr hb + push_cast at this; exact this + have hab' : (a : ℝ) ≤ b := by exact_mod_cast hab + have hA0 : (0 : ℝ) ≤ a := by exact_mod_cast ha0q + have hs0 : 0 ≤ 1 - t := by linarith + have hs1 : 1 - t ≤ 1 := by linarith + have hσ : ∀ a' b' : ℕ, 1 ≤ a' → a' ≤ b' → b' ≤ 8 → c2 (gs (1 - t)) (a' : ℝ) (b' : ℝ) ≤ (σ : ℝ) := by + intro a' b' h1' h2' h3' + exact sig_of_ok (1 - b) (1 - a) σ hσc (by linarith) (by linarith) hσ0 (1 - t) + (by push_cast; linarith) (by push_cast; linarith) a' b' h1' h2' h3' + have hLcp' := hLcp (1 - t) (by push_cast; linarith) (by push_cast; linarith) + have hslo : (9 / 10 : ℝ) ≤ 1 - t := by linarith + have hshi : 1 - t ≤ 1 - ((tZ0 : ℚ) : ℝ) := by linarith + have hell : 0 ≤ ellC spF (1 - t) := hLcp'.2 + have hE := E_lower_cap_omN R nR dR J (distF (1 - t)) (E (1 - t)) (1 - t) (capC (1 - t)) (corrC cstF (1 - t)) (ellC spF (1 - t)) + (σ : ℝ) (Omega ks mr (1 - t)) 5 0 hmono hd9 hmix (by exact_mod_cast hσ0) hσ (hcong (1 - t) hslo hshi) (hEex _ hs0 hs1) + (fun p hp => le_min (le_trans (min_le_left _ _) (hdist (1 - t) hslo hshi p hp)) (min_le_right _ _)) (Nat.zero_le _) hell + have hE' : (((lcp - 5 * σ : ℚ)) : ℝ) ≤ E (1 - t) + Omega ks mr (1 - t) := by + push_cast; push_cast at hE; linarith [hLcp'.1] + exact branchC_om n ks mr (E (1 - t)) _ (1 - t) (hF _ hs0 hs1) hE' + (hFb (1 - t) (by push_cast; linarith) (by push_cast; linarith)) + intro t ht ht1 + have ht0 : (0 : ℝ) ≤ ((tZ0 : ℚ) : ℝ) := by unfold tZ0; norm_num + have hs0 : (0 : ℝ) ≤ 1 - t := by linarith + have hs1 : 1 - t ≤ 1 := by linarith + have hu1 : (1 : ℝ) ≤ (2 : ℝ) ^ (1 - t) := Real.one_le_rpow (by norm_num) hs0 + have hu2 : (2 : ℝ) ^ (1 - t) ≤ 2 := by + have := Real.rpow_le_rpow_of_exponent_le (show (1 : ℝ) ≤ 2 by norm_num) hs1; simpa using this + have hE0 : 0 ≤ E (1 - t) := + le_trans (mul_nonneg (by linarith) (Nat.cast_nonneg st)) (hst _ hs0 hs1) + rcases le_or_gt (1 / 10 : ℝ) t with h10 | h10 + · have h2 := invoice_F (1 - t) (caller 6 7) n 17 + have h3 := invoice_F (1 - t) (caller 6 7) natBaseC 17 + have h4 := natBaseC_F (1 - t) + push_cast at h2 h3 + have h1 := own56_floor (1 - t) hs0 hs1 ks hk hmass hmd mr st hmr (Finv (1 - t) n) (E (1 - t)) 0 (hF _ hs0 hs1) hY + (hst _ hs0 hs1) hE0 + have hc0 : (0 : ℝ) ≤ 88 * (2 - (2 : ℝ) ^ (1 - t)) := by linarith + rw [max_eq_left hc0] at h1 + have h5 := cfC88_neg (1 - t) hs0 (by linarith) + have h6 := base88_eq (1 - t) + nlinarith + · obtain ⟨sp0, sp1, sp2, sp3, sp4⟩ := hspTabN + obtain ⟨cs0, cs1, cs2, cs3, cs4⟩ := hcstTabN + have q01 : tZ0 ≤ tZ1 := by unfold tZ0 tZ1; norm_num + have q12 : tZ1 ≤ tZ2 := by unfold tZ1 tZ2; norm_num + have q23 : tZ2 ≤ tZ3 := by unfold tZ2 tZ3; norm_num + have q34 : tZ3 ≤ tZ4 := by unfold tZ3 tZ4; norm_num + have q45 : tZ4 ≤ tZ5 := by unfold tZ4 tZ5; norm_num + have b1 : tZ1 ≤ 1 / 10 := by unfold tZ1; norm_num + have b2 : tZ2 ≤ 1 / 10 := by unfold tZ2; norm_num + have b3 : tZ3 ≤ 1 / 10 := by unfold tZ3; norm_num + have b4 : tZ4 ≤ 1 / 10 := by unfold tZ4; norm_num + have b5 : tZ5 ≤ 1 / 10 := by unfold tZ5; norm_num + have q02 := le_trans q01 q12 + have q03 := le_trans q02 q23 + have q04 := le_trans q03 q34 + have un0 := unit_of_Fup tZ1 unitLoZ0 (by unfold tZ1; norm_num) (by unfold tZ1; norm_num) unitZ0 + have un1 := unit_of_Fup tZ2 unitLoZ1 (by unfold tZ2; norm_num) (by unfold tZ2; norm_num) unitZ1 + have un2 := unit_of_Fup tZ3 unitLoZ2 (by unfold tZ3; norm_num) (by unfold tZ3; norm_num) unitZ2 + have un3 := unit_of_Fup tZ4 unitLoZ3 (by unfold tZ4; norm_num) (by unfold tZ4; norm_num) unitZ3 + have un4 := unit_of_Fup tZ5 unitLoZ4 (by unfold tZ5; norm_num) (by unfold tZ5; norm_num) unitZ4 + have zspFloN0 : (0 : ℚ) ≤ spFloZ0 := by unfold spFloZ0; norm_num + have zspFloN1 : (0 : ℚ) ≤ spFloZ1 := by unfold spFloZ1; norm_num + have zspFloN2 : (0 : ℚ) ≤ spFloZ2 := by unfold spFloZ2; norm_num + have zspFloN3 : (0 : ℚ) ≤ spFloZ3 := by unfold spFloZ3; norm_num + have zspFloN4 : (0 : ℚ) ≤ spFloZ4 := by unfold spFloZ4; norm_num + have zcHN0 : (0 : ℚ) ≤ cHZ0 := by unfold cHZ0; norm_num + have zcHN1 : (0 : ℚ) ≤ cHZ1 := by unfold cHZ1; norm_num + have zcHN2 : (0 : ℚ) ≤ cHZ2 := by unfold cHZ2; norm_num + have zcHN3 : (0 : ℚ) ≤ cHZ3 := by unfold cHZ3; norm_num + have zcHN4 : (0 : ℚ) ≤ cHZ4 := by unfold cHZ4; norm_num + have zunitLoN0 : (0 : ℚ) ≤ unitLoZ0 := by unfold unitLoZ0; norm_num + have zunitLoN1 : (0 : ℚ) ≤ unitLoZ1 := by unfold unitLoZ1; norm_num + have zunitLoN2 : (0 : ℚ) ≤ unitLoZ2 := by unfold unitLoZ2; norm_num + have zunitLoN3 : (0 : ℚ) ≤ unitLoZ3 := by unfold unitLoZ3; norm_num + have zunitLoN4 : (0 : ℚ) ≤ unitLoZ4 := by unfold unitLoZ4; norm_num + have hF4 : ∀ (a b L : ℚ), 93 / 100 ≤ 1 - b → a ≤ b → tZ0 ≤ a → Fup cfC (1 - a) (1 - a) < 17 * L → + ∀ s : ℝ, ((1 - b : ℚ) : ℝ) ≤ s → s ≤ ((1 - a : ℚ) : ℝ) → Fc cfC s < 17 * (L : ℝ) := by + intro a b L hb93 hab haN hpt + exact hFbJ_of a b L hb93 hab (le_trans (by unfold tJ0 tZ0; norm_num) haN) hpt + by_cases k1 : t ≤ ((tZ1 : ℚ) : ℝ) + · exact piece tZ0 tZ1 lcpZ0 sgZ0 sigZ0 (by unfold sgZ0; norm_num) (le_refl _) q01 b1 + (tab_pieceZ spF cstF tZ0 tZ1 lcpZ0 cHZ0 spFloZ0 unitLoZ0 zcHN0 zspFloN0 zunitLoN0 (le_refl _) q01 b1 + hspMono hcstMono sp0 cs0 un0 tabZ0.1 tabZ0.2) + (hF4 tZ0 tZ1 LZ0 (by unfold tZ1; norm_num) q01 (le_refl _) ptZ0) t ht k1 + by_cases k2 : t ≤ ((tZ2 : ℚ) : ℝ) + · exact piece tZ1 tZ2 lcpZ1 sgZ1 sigZ1 (by unfold sgZ1; norm_num) q01 q12 b2 + (tab_pieceZ spF cstF tZ1 tZ2 lcpZ1 cHZ1 spFloZ1 unitLoZ1 zcHN1 zspFloN1 zunitLoN1 q01 q12 b2 + hspMono hcstMono sp1 cs1 un1 tabZ1.1 tabZ1.2) + (hF4 tZ1 tZ2 LZ1 (by unfold tZ2; norm_num) q12 q01 ptZ1) t (by push Not at k1; exact k1.le) k2 + by_cases k3 : t ≤ ((tZ3 : ℚ) : ℝ) + · exact piece tZ2 tZ3 lcpZ2 sgZ2 sigZ2 (by unfold sgZ2; norm_num) q02 q23 b3 + (tab_pieceZ spF cstF tZ2 tZ3 lcpZ2 cHZ2 spFloZ2 unitLoZ2 zcHN2 zspFloN2 zunitLoN2 q02 q23 b3 + hspMono hcstMono sp2 cs2 un2 tabZ2.1 tabZ2.2) + (hF4 tZ2 tZ3 LZ2 (by unfold tZ3; norm_num) q23 q02 ptZ2) t (by push Not at k2; exact k2.le) k3 + by_cases k4 : t ≤ ((tZ4 : ℚ) : ℝ) + · exact piece tZ3 tZ4 lcpZ3 sgZ3 sigZ3 (by unfold sgZ3; norm_num) q03 q34 b4 + (tab_pieceZ spF cstF tZ3 tZ4 lcpZ3 cHZ3 spFloZ3 unitLoZ3 zcHN3 zspFloN3 zunitLoN3 q03 q34 b4 + hspMono hcstMono sp3 cs3 un3 tabZ3.1 tabZ3.2) + (hF4 tZ3 tZ4 LZ3 (by unfold tZ4; norm_num) q34 q03 ptZ3) t (by push Not at k3; exact k3.le) k4 + · refine piece tZ4 tZ5 lcpZ4 sgZ4 sigZ4 (by unfold sgZ4; norm_num) q04 q45 b5 + (tab_pieceZ spF cstF tZ4 tZ5 lcpZ4 cHZ4 spFloZ4 unitLoZ4 zcHN4 zspFloN4 zunitLoN4 q04 q45 b5 + hspMono hcstMono sp4 cs4 un4 tabZ4.1 tabZ4.2) ?_ t (by push Not at k4; exact k4.le) (by unfold tZ5; push_cast; exact h10.le) + intro s hs1' hs2' + have e1 : (((1 - tZ5 : ℚ)) : ℝ) = 9 / 10 := by unfold tZ5; norm_num + have e2 : (((1 - tZ4 : ℚ)) : ℝ) = 93 / 100 := by unfold tZ4; norm_num + rw [e1] at hs1'; rw [e2] at hs2' + have hq : (((17 * LZ4 : ℚ)) : ℝ) = 17 * (((lcpZ4 - 5 * sgZ4 : ℚ)) : ℝ) := by unfold LZ4; push_cast; ring + by_cases hm : s ≤ 915 / 1000 + · have := Fc_le cfC cfC_ok (9 / 10) (915 / 1000) (by norm_num) (by norm_num) s (by push_cast; exact hs1') (by push_cast; exact hm) + have h2 : ((Fup cfC (9 / 10) (915 / 1000) : ℚ) : ℝ) < (((17 * LZ4 : ℚ)) : ℝ) := by exact_mod_cast boxZ4a + linarith + · push Not at hm + have := Fc_le cfC cfC_ok (915 / 1000) (93 / 100) (by norm_num) (by norm_num) s (by push_cast; exact hm.le) (by push_cast; exact hs2') + have h2 : ((Fup cfC (915 / 1000) (93 / 100) : ℚ) : ℝ) < (((17 * LZ4 : ℚ)) : ℝ) := by exact_mod_cast boxZ4b + linarith + +end CongestionNative + +#print axioms CongestionNative.tab_pieceZ +#print axioms CongestionNative.ceiling_native_Z0 diff --git a/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeZDefs.lean b/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeZDefs.lean new file mode 100644 index 0000000000..c1286165a5 --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeZDefs.lean @@ -0,0 +1,55 @@ +import Mathlib.Data.Rat.Defs +import Mathlib.Tactic.NormNum + +/-! CONGESTION-NATIVE-Z0 tables. Source: internal table generators (N = 0; +spF_lo / unit_lo rounded DOWN to 14 digits, cst rounded UP, outward Decimal 80 digits). -/ +namespace CongestionNative + +def tZ0 : ℚ := 151869 / 10 ^ 7 +def tZ1 : ℚ := 151889 / 10 ^ 7 +def tZ2 : ℚ := 152889 / 10 ^ 7 +def tZ3 : ℚ := 202889 / 10 ^ 7 +def tZ4 : ℚ := 7 / 100 +def tZ5 : ℚ := 1 / 10 +def sgZ0 : ℚ := 31097 / 500000 +def cHZ0 : ℚ := 74803 / 2000000 +def lcpZ0 : ℚ := -74803 / 250000 +def LZ0 : ℚ := lcpZ0 - 5 * sgZ0 +def spFloZ0 : ℚ := 363952451801 / 50000000000000 +def unitLoZ0 : ℚ := 1906645468203 / 2000000000000 +def sgZ1 : ℚ := 31749 / 500000 +def cHZ1 : ℚ := 188219 / 5000000 +def lcpZ1 : ℚ := -301151 / 1000000 +def LZ1 : ℚ := lcpZ1 - 5 * sgZ1 +def spFloZ1 : ℚ := 727999600691 / 100000000000000 +def unitLoZ1 : ℚ := 95302201336951 / 100000000000000 +def sgZ2 : ℚ := 25673 / 200000 +def cHZ2 : ℚ := 496937 / 10000000 +def lcpZ2 : ℚ := -7951 / 20000 +def LZ2 : ℚ := lcpZ2 - 5 * sgZ2 +def spFloZ2 : ℚ := 366367033967 / 50000000000000 +def unitLoZ2 : ℚ := 23452348528969 / 25000000000000 +def sgZ3 : ℚ := 32509 / 40000 +def cHZ3 : ℚ := 1628077 / 10000000 +def lcpZ3 : ℚ := -651231 / 500000 +def LZ3 : ℚ := lcpZ3 - 5 * sgZ3 +def spFloZ3 : ℚ := 968491930913 / 100000000000000 +def unitLoZ3 : ℚ := 5004058989633 / 6250000000000 +def sgZ4 : ℚ := 24423 / 40000 +def cHZ4 : ℚ := 2255027 / 10000000 +def lcpZ4 : ℚ := -902011 / 500000 +def LZ4 : ℚ := lcpZ4 - 5 * sgZ4 +def spFloZ4 : ℚ := 3212352863571 / 100000000000000 +def unitLoZ4 : ℚ := 72665488499219 / 100000000000000 +theorem tabZ0 : lcpZ0 + 8 * cHZ0 ≤ 0 * spFloZ0 ∧ lcpZ0 + 8 * cHZ0 ≤ 0 * (unitLoZ0 / 48) := by + unfold lcpZ0 cHZ0 spFloZ0 unitLoZ0; constructor <;> norm_num +theorem tabZ1 : lcpZ1 + 8 * cHZ1 ≤ 0 * spFloZ1 ∧ lcpZ1 + 8 * cHZ1 ≤ 0 * (unitLoZ1 / 48) := by + unfold lcpZ1 cHZ1 spFloZ1 unitLoZ1; constructor <;> norm_num +theorem tabZ2 : lcpZ2 + 8 * cHZ2 ≤ 0 * spFloZ2 ∧ lcpZ2 + 8 * cHZ2 ≤ 0 * (unitLoZ2 / 48) := by + unfold lcpZ2 cHZ2 spFloZ2 unitLoZ2; constructor <;> norm_num +theorem tabZ3 : lcpZ3 + 8 * cHZ3 ≤ 0 * spFloZ3 ∧ lcpZ3 + 8 * cHZ3 ≤ 0 * (unitLoZ3 / 48) := by + unfold lcpZ3 cHZ3 spFloZ3 unitLoZ3; constructor <;> norm_num +theorem tabZ4 : lcpZ4 + 8 * cHZ4 ≤ 0 * spFloZ4 ∧ lcpZ4 + 8 * cHZ4 ≤ 0 * (unitLoZ4 / 48) := by + unfold lcpZ4 cHZ4 spFloZ4 unitLoZ4; constructor <;> norm_num + +end CongestionNative diff --git a/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeZPt.lean b/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeZPt.lean new file mode 100644 index 0000000000..e33a184bd5 --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeZPt.lean @@ -0,0 +1,14 @@ +import Nov15.CongestionI3DualConst +import Nov15.CongestionI3NumC1 +import Nov15.CongestionNativeJUnit +import Nov15.CongestionNativeZDefs +namespace CongestionNative +open NumCertK CongestionI3 CongestionI3Dual +theorem cfC_dZ : 0 < dLo cfC (93 / 100) (1 - tZ0) := by unfold tZ0; decide +kernel +theorem ptZ0 : Fup cfC (1 - tZ0) (1 - tZ0) < 17 * LZ0 := by unfold tZ0 LZ0 lcpZ0 sgZ0; decide +kernel +theorem ptZ1 : Fup cfC (1 - tZ1) (1 - tZ1) < 17 * LZ1 := by unfold tZ1 LZ1 lcpZ1 sgZ1; decide +kernel +theorem ptZ2 : Fup cfC (1 - tZ2) (1 - tZ2) < 17 * LZ2 := by unfold tZ2 LZ2 lcpZ2 sgZ2; decide +kernel +theorem ptZ3 : Fup cfC (1 - tZ3) (1 - tZ3) < 17 * LZ3 := by unfold tZ3 LZ3 lcpZ3 sgZ3; decide +kernel +theorem boxZ4a : Fup cfC (9 / 10) (915 / 1000) < 17 * LZ4 := by unfold LZ4 lcpZ4 sgZ4; decide +kernel +theorem boxZ4b : Fup cfC (915 / 1000) (93 / 100) < 17 * LZ4 := by unfold LZ4 lcpZ4 sgZ4; decide +kernel +end CongestionNative diff --git a/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeZSig0.lean b/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeZSig0.lean new file mode 100644 index 0000000000..dee0494039 --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeZSig0.lean @@ -0,0 +1,7 @@ +import Nov15.CongestionI3DualSig +import Nov15.CongestionI3NumC1 +import Nov15.CongestionNativeZDefs +namespace CongestionNative +open NumCertK CongestionI3 CongestionI3Dual +theorem sigZ0 : sigOK (1 - tZ1) (1 - tZ0) sgZ0 = true := by unfold tZ0 tZ1 sgZ0; decide +kernel +end CongestionNative diff --git a/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeZSig1.lean b/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeZSig1.lean new file mode 100644 index 0000000000..9e34aa8dde --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeZSig1.lean @@ -0,0 +1,7 @@ +import Nov15.CongestionI3DualSig +import Nov15.CongestionI3NumC1 +import Nov15.CongestionNativeZDefs +namespace CongestionNative +open NumCertK CongestionI3 CongestionI3Dual +theorem sigZ1 : sigOK (1 - tZ2) (1 - tZ1) sgZ1 = true := by unfold tZ1 tZ2 sgZ1; decide +kernel +end CongestionNative diff --git a/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeZSig2.lean b/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeZSig2.lean new file mode 100644 index 0000000000..8f999d2bee --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeZSig2.lean @@ -0,0 +1,7 @@ +import Nov15.CongestionI3DualSig +import Nov15.CongestionI3NumC1 +import Nov15.CongestionNativeZDefs +namespace CongestionNative +open NumCertK CongestionI3 CongestionI3Dual +theorem sigZ2 : sigOK (1 - tZ3) (1 - tZ2) sgZ2 = true := by unfold tZ2 tZ3 sgZ2; decide +kernel +end CongestionNative diff --git a/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeZSig3.lean b/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeZSig3.lean new file mode 100644 index 0000000000..1dfd1bea8a --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeZSig3.lean @@ -0,0 +1,7 @@ +import Nov15.CongestionI3DualSig +import Nov15.CongestionI3NumC1 +import Nov15.CongestionNativeZDefs +namespace CongestionNative +open NumCertK CongestionI3 CongestionI3Dual +theorem sigZ3 : sigOK (1 - tZ4) (1 - tZ3) sgZ3 = true := by unfold tZ3 tZ4 sgZ3; decide +kernel +end CongestionNative diff --git a/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeZSig4.lean b/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeZSig4.lean new file mode 100644 index 0000000000..0b8ab05185 --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeZSig4.lean @@ -0,0 +1,7 @@ +import Nov15.CongestionI3DualSig +import Nov15.CongestionI3NumC1 +import Nov15.CongestionNativeZDefs +namespace CongestionNative +open NumCertK CongestionI3 CongestionI3Dual +theorem sigZ4 : sigOK (1 - tZ5) (1 - tZ4) sgZ4 = true := by unfold tZ4 tZ5 sgZ4; decide +kernel +end CongestionNative diff --git a/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeZUnit.lean b/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeZUnit.lean new file mode 100644 index 0000000000..0d78eadfcc --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/CongestionNativeZUnit.lean @@ -0,0 +1,10 @@ +import Nov15.CongestionNativeJUnit +import Nov15.CongestionNativeZDefs +namespace CongestionNative +open NumCertK CongestionI3 CongestionI3Dual +theorem unitZ0 : Fup unitCF (1 - tZ1) (1 - tZ1) < -unitLoZ0 := by unfold tZ1 unitLoZ0; decide +kernel +theorem unitZ1 : Fup unitCF (1 - tZ2) (1 - tZ2) < -unitLoZ1 := by unfold tZ2 unitLoZ1; decide +kernel +theorem unitZ2 : Fup unitCF (1 - tZ3) (1 - tZ3) < -unitLoZ2 := by unfold tZ3 unitLoZ2; decide +kernel +theorem unitZ3 : Fup unitCF (1 - tZ4) (1 - tZ4) < -unitLoZ3 := by unfold tZ4 unitLoZ3; decide +kernel +theorem unitZ4 : Fup unitCF (1 - tZ5) (1 - tZ5) < -unitLoZ4 := by unfold tZ5 unitLoZ4; decide +kernel +end CongestionNative diff --git a/research/p104-tiered-ceiling/lean/Nov15/FibreK.lean b/research/p104-tiered-ceiling/lean/Nov15/FibreK.lean new file mode 100644 index 0000000000..33e2d3f083 --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/FibreK.lean @@ -0,0 +1,537 @@ +/- +FibreK . See FibreK.md. Formalises the AUDITED parts of internal notes,2}.md, AUDIT2.md. + +Part 1 THEOREM K. Price premise P0 as an explicit hypothesis (a `Table`: the ranks charged for a helper climb d = e - b on T, + and for a helper MOVE of |dim step| = d on P). The invoice F(t) = sum_r (T_r - P_r) r^(1-t) of the word is + `FK E tb S Pi t`: a function of the ends E, the step multiset S and the climb multiset Pi only (`K_word`, `K_invoice`). +Part 2 G2 for PURE relabels. Helpers end identity; hub gauge L in Blk(V'), M in Blk(G0) (SwapNull.Blk / Undo). + * tail: row relabel (SwapNull.rowSw), V' = sigma^-1 V (the corrected hypothesis), `tail_pairs`; + * head: column relabel (SwapNull.colSw), prefix block G1 = the NEW births-at-0 set, proved DIRECTLY `head_pairs`; + the (birth,end) multiset, hence Pi, hence F(t) by K, is unchanged. +Kernel only: no sorry, no native_decide. +-/ +import Nov15.SwapNull +import Nov15.CallerCost + +set_option linter.unusedSectionVars false +set_option linter.unusedVariables false + +namespace FibreK +open CallerCost + +/-! ### Part 1: THEOREM K -/ + +/-- P0: rank tables. `tT d` = ranks charged to T for a helper with climb d = e - b; +`tP d` = ranks charged to P for a helper MOVE with |Δdim| = d. (Hist = (rank, count) lists.) -/ +structure Table where + tT : ℕ → Hist + tP : ℕ → Hist + +/-- A helper: birth dim, end dim, and its MOVE steps as (source dim, target dim). -/ +structure Helper where + b : ℕ + e : ℕ + steps : List (ℕ × ℕ) + +def gap (s : ℕ × ℕ) : ℕ := Int.natAbs ((s.2 : ℤ) - s.1) + +/-- F-contribution of a histogram: sum count * rank^(1-t). -/ +noncomputable def Fh (l : Hist) (t : ℝ) : ℝ := (l.map fun p => (p.2 : ℝ) * (p.1 : ℝ) ^ (1 - t)).sum +noncomputable def Fi (i : Inv) (t : ℝ) : ℝ := Fh i.T t - Fh i.P t + +theorem Fh_append (l m : Hist) (t : ℝ) : Fh (l ++ m) t = Fh l t + Fh m t := by simp [Fh] + +theorem Fh_scale (L : ℕ) (l : Hist) (t : ℝ) : Fh (scale L l) t = L * Fh l t := by + induction l with + | nil => simp [Fh, scale] + | cons p l ih => + simp only [Fh, scale, List.map_cons, List.sum_cons] at ih ⊢ + rw [ih]; push_cast; ring + +theorem Fh_flatMap {α : Type*} (l : List α) (g : α → Hist) (t : ℝ) : + Fh (l.flatMap g) t = (l.map fun x => Fh (g x) t).sum := by + induction l with + | nil => simp [Fh] + | cons x l ih => simp [List.flatMap_cons, Fh_append, ih] + +/-- invoice = caller + L * native, at the level of F. -/ +theorem Fi_invoice (c n : Inv) (L : ℕ) (t : ℝ) : + Fi (invoice c n L) t = Fi c t + L * Fi n t := by + simp only [Fi, invoice, Fh_append, Fh_scale]; ring + +/-- the native's invoice histograms from the helper list (P0). -/ +def nativeInv (E : Inv) (tb : Table) (H : List Helper) : Inv := + ⟨E.T ++ H.flatMap fun h => tb.tT (h.e - h.b), + E.P ++ H.flatMap fun h => h.steps.flatMap fun s => tb.tP (gap s)⟩ + +/-- the timed-step data: S = multiset of all helper MOVEs, Pi = multiset of climbs e - b. -/ +def Ssum (H : List Helper) : Multiset (ℕ × ℕ) := ↑(H.flatMap Helper.steps) +def PiW (H : List Helper) : Multiset ℕ := ↑(H.map fun h => h.e - h.b) + +/-- F as a function of the DATA (E, S, Pi). -/ +noncomputable def FK (E : Inv) (tb : Table) (S : Multiset (ℕ × ℕ)) (Pi : Multiset ℕ) (t : ℝ) : ℝ := + Fi E t + (Pi.map fun d => Fh (tb.tT d) t).sum - (S.map fun s => Fh (tb.tP (gap s)) t).sum + +theorem sum_flatMap_map {α β : Type*} (H : List α) (g : α → List β) (φ : β → ℝ) : + ((H.flatMap g).map φ).sum = (H.map fun h => ((g h).map φ).sum).sum := by + induction H with + | nil => simp + | cons h H ih => simp [List.flatMap_cons, List.map_append, List.sum_append, ih] + +/-- **THEOREM K** (P0 as hypothesis `tb`): the word's F is `FK` of its (E, S, Pi). -/ +theorem K_word (E : Inv) (tb : Table) (H : List Helper) (t : ℝ) : + Fi (nativeInv E tb H) t = FK E tb (Ssum H) (PiW H) t := by + simp only [Fi, nativeInv, FK, Ssum, PiW, Fh_append, Fh_flatMap, Multiset.map_coe, Multiset.sum_coe] + rw [sum_flatMap_map] + have : ∀ h : Helper, (h.steps.map fun s => Fh (tb.tP (gap s)) t).sum + = Fh (h.steps.flatMap fun s => tb.tP (gap s)) t := fun h => (Fh_flatMap _ _ _).symm + simp only [List.map_map, Function.comp_def, this] + ring + +/-- κ depends only on (E, S, Pi): two words with the same data have the same F, so the same roots. -/ +theorem K_congr (E : Inv) (tb : Table) (H H' : List Helper) + (hS : Ssum H' = Ssum H) (hP : PiW H' = PiW H) (t : ℝ) : + Fi (nativeInv E tb H') t = Fi (nativeInv E tb H) t := by + rw [K_word, K_word, hS, hP] + +/-- the caller invoice of the native (calls = L) is a function of (E, S, Pi) (and the fixed caller). -/ +theorem K_invoice (c E : Inv) (tb : Table) (H : List Helper) (L : ℕ) (t : ℝ) : + Fi (invoice c (nativeInv E tb H) L) t = Fi c t + L * FK E tb (Ssum H) (PiW H) t := by + rw [Fi_invoice, K_word] + +/-- κ = a root of F: invariant when F is. -/ +def IsRoot (F : ℝ → ℝ) (κ : ℝ) : Prop := F κ = 0 + +theorem kappa_depends_only (c E : Inv) (tb : Table) (H H' : List Helper) (L : ℕ) + (hS : Ssum H' = Ssum H) (hP : PiW H' = PiW H) (κ : ℝ) : + IsRoot (Fi (invoice c (nativeInv E tb H') L)) κ ↔ IsRoot (Fi (invoice c (nativeInv E tb H) L)) κ := by + unfold IsRoot + rw [K_invoice, K_invoice, hS, hP] + +/-- the instance used by FloorD0 / V2Bridge: D0 table `tT d = tP d = [(d, 1)]`; then the helper part is +Σ_h [f(e-b) - Σ_steps f(gap)] (the per-helper D0 identity). -/ +def d0Table : Table := ⟨fun d => [(d, 1)], fun d => [(d, 1)]⟩ + +theorem Dh_flatMap {α : Type*} (l : List α) (g : α → Hist) : + Dh (l.flatMap g) = (l.map fun x => Dh (g x)).sum := by + induction l with + | nil => simp [Dh] + | cons x l ih => simp [List.flatMap_cons, Dh_append, ih] + +theorem d0_native (E : Inv) (H : List Helper) : + Dinv (nativeInv E d0Table H) = Dinv E + (H.map fun h => + (fL (h.e - h.b) - (h.steps.map fun s => fL (gap s)).sum)).sum := by + simp only [Dinv, nativeInv, Dh_append, Dh_flatMap, d0Table] + have h1 : ∀ h : Helper, Dh [(h.e - h.b, 1)] = fL (h.e - h.b) := by intro h; simp [Dh] + have h2 : ∀ h : Helper, (h.steps.map fun s => Dh [(gap s, 1)]).sum = (h.steps.map fun s => fL (gap s)).sum := by + intro h; simp [Dh] + have hs : ∀ (l : List Helper) (a b : Helper → ℝ), + (l.map fun h => a h - b h).sum = (l.map a).sum - (l.map b).sum := by + intro l a b + induction l with + | nil => simp + | cons x l ih => simp [ih]; ring + simp only [h1, h2] + rw [hs] + ring + +/-! ### Part 2: G2 for pure relabels -/ +section G2 +open SwapNull +variable {K Reg : Type*} [Field K] [Fintype Reg] [DecidableEq Reg] + +/-- helpers end identity: the final row of a helper is its own unit vector. -/ +def HelpersId (H : Reg → Prop) (F : Matrix Reg Reg K) : Prop := + ∀ x, H x → ∀ k, F x k = (1 : Matrix Reg Reg K) x k + +/-- Row x ∉ V' of L * A * M is the row of A * M. -/ +theorem lrow {V' : Reg → Prop} {L : Matrix Reg Reg K} (hL : Blk V' L) (A : Matrix Reg Reg K) + {x : Reg} (hx : ¬ V' x) (j : Reg) : (L * A) x j = A x j := by + rw [Matrix.mul_apply, Finset.sum_eq_single x] + · rw [hL x x (fun h => hx h.1)]; simp + · intro i _ hi; rw [hL x i (fun h => hx h.1), Matrix.one_apply_ne (Ne.symm hi)]; simp + · simp + +/-- TAIL force: if L ∈ Blk(V'), M ∈ Blk(G0) undo a row relabel of an identity-final matrix, every moved +helper x ∉ V' has x and σ x in G0. -/ +theorem tail_force {H V' G0 : Reg → Prop} {F : Matrix Reg Reg K} (hF : HelpersId H F) + (σ : Equiv.Perm Reg) (hσH : ∀ x, H x → H (σ x)) + (hu : Undo V' G0 F (rowSw σ F)) {x : Reg} (hx : H x) (hV : ¬ V' x) (hm : σ x ≠ x) : + G0 x ∧ G0 (σ x) := by + obtain ⟨L, M, hL, hM, h⟩ := hu + have key : ∀ k, M (σ x) k = (1 : Matrix Reg Reg K) x k := by + intro k + have h1 : (L * rowSw σ F * M) x k = M (σ x) k := by + rw [Matrix.mul_apply, Finset.sum_eq_single (σ x)] + · rw [lrow hL _ hV]; simp [rowSw, hF (σ x) (hσH x hx)] + · intro j _ hj + rw [lrow hL _ hV]; simp [rowSw, hF (σ x) (hσH x hx), Matrix.one_apply_ne (Ne.symm hj)] + · simp + rw [← h1, h]; exact hF x hx k + constructor + · by_contra hg + have := hM (σ x) x (fun h => hg h.2) + rw [key x, Matrix.one_apply_ne hm] at this + simp at this + · by_contra hg + have := hM (σ x) (σ x) (fun h => hg h.1) + rw [key (σ x), Matrix.one_apply_ne (Ne.symm hm)] at this + simp at this + +/-- HEAD force (direct, not by time reversal): a column relabel undone by L ∈ Blk(V), M ∈ Blk(G1): +every moved helper x ∉ V has σ⁻¹ x and x in G1. -/ +theorem head_force {H V G1 : Reg → Prop} {F : Matrix Reg Reg K} (hF : HelpersId H F) + (σ : Equiv.Perm Reg) + (hu : Undo V G1 F (colSw σ F)) {x : Reg} (hx : H x) (hV : ¬ V x) (hm : σ x ≠ x) : + G1 (σ.symm x) ∧ G1 x := by + obtain ⟨L, M, hL, hM, h⟩ := hu + have key : ∀ k, M (σ.symm x) k = (1 : Matrix Reg Reg K) x k := by + intro k + have h1 : (L * colSw σ F * M) x k = M (σ.symm x) k := by + rw [Matrix.mul_apply, Finset.sum_eq_single (σ.symm x)] + · rw [lrow hL _ hV]; simp [colSw, hF x hx] + · intro j _ hj + rw [lrow hL _ hV] + have : x ≠ σ j := fun e => hj (by rw [e]; simp) + simp [colSw, hF x hx, Matrix.one_apply_ne this] + · simp + rw [← h1, h]; exact hF x hx k + have hy : σ.symm x ≠ x := fun e => hm (by + have := congrArg σ e; simpa using this.symm) + constructor + · by_contra hg + have := hM (σ.symm x) (σ.symm x) (fun h => hg h.1) + rw [key (σ.symm x), Matrix.one_apply_ne (Ne.symm hy)] at this + simp at this + · by_contra hg + have := hM (σ.symm x) x (fun h => hg h.2) + rw [key x, Matrix.one_apply_ne hy] at this + simp at this + +/-! counting lemma: equal cardinality, differing only on birth-0 elements, so equal birth multisets -/ +theorem map_birth_eq (β : Reg → ℕ) (A B : Finset Reg) (hc : A.card = B.card) + (hA : ∀ x ∈ A, x ∉ B → β x = 0) (hB : ∀ x ∈ B, x ∉ A → β x = 0) : + A.val.map β = B.val.map β := by + classical + have hne : ∀ b : ℕ, b ≠ 0 → A.filter (fun x => b = β x) = B.filter (fun x => b = β x) := by + intro b hb + ext x + simp only [Finset.mem_filter] + constructor + · rintro ⟨ha, e⟩ + refine ⟨?_, e⟩ + by_contra hn + exact hb (e.trans (hA x ha hn)) + · rintro ⟨ha, e⟩ + refine ⟨?_, e⟩ + by_contra hn + exact hb (e.trans (hB x ha hn)) + apply Multiset.ext.2 + intro b + rw [Multiset.count_map, Multiset.count_map] + simp only [← Finset.filter_val, Finset.card_val] + by_cases hb : b = 0 + · subst hb + have h1 := Finset.card_filter_add_card_filter_not (s := A) (fun x => 0 = β x) + have h2 := Finset.card_filter_add_card_filter_not (s := B) (fun x => 0 = β x) + have h3 : A.filter (fun x => ¬ (0 = β x)) = B.filter (fun x => ¬ (0 = β x)) := by + ext x + simp only [Finset.mem_filter] + constructor + · rintro ⟨ha, e⟩ + refine ⟨?_, e⟩ + by_contra hn + exact e (hA x ha hn).symm + · rintro ⟨ha, e⟩ + refine ⟨?_, e⟩ + by_contra hn + exact e (hB x ha hn).symm + rw [h3] at h1 + omega + · rw [hne b hb] + +variable (β ε : Reg → ℕ) (d : ℕ) + +/-- birth/end pairs of the helpers `Hs`. -/ +def pairs (Hs : Finset Reg) : Multiset (ℕ × ℕ) := Hs.val.map fun x => (β x, ε x) +/-- after a tail relabel x keeps its birth but takes σ x's end. -/ +def pairsTail (σ : Equiv.Perm Reg) (Hs : Finset Reg) : Multiset (ℕ × ℕ) := + Hs.val.map fun x => (β x, ε (σ x)) +/-- after a head relabel x takes σ x's birth but keeps its end. -/ +def pairsHead (σ : Equiv.Perm Reg) (Hs : Finset Reg) : Multiset (ℕ × ℕ) := + Hs.val.map fun x => (β (σ x), ε x) + +theorem sigma_H {H : Reg → Prop} (σ : Equiv.Perm Reg) (hσ : ∀ x, ¬ H x → σ x = x) : + ∀ x, H x → H (σ x) := by + intro x hx + by_contra h + have h1 := hσ _ h + have : σ x = x := σ.injective h1 + exact h (by rw [this]; exact hx) + +theorem split_map {α γ : Type*} (s : Multiset α) (p : α → Prop) [DecidablePred p] (f : α → γ) : + s.map f = (s.filter p).map f + (s.filter (fun x => ¬ p x)).map f := by + rw [← Multiset.map_add, Multiset.filter_add_not] + +/-- the (birth, end) pair multiset determines the climb multiset Pi -/ +def PiOf (ps : Multiset (ℕ × ℕ)) : Multiset ℕ := ps.map fun p => p.2 - p.1 + +theorem PiW_eq (H : List Helper) : PiW H = PiOf (↑(H.map fun h => (h.b, h.e)) : Multiset (ℕ × ℕ)) := by + simp [PiW, PiOf, Multiset.map_coe, List.map_map, Function.comp_def] + +section Pairs + +theorem symm_fix (σ : Equiv.Perm Reg) (x : Reg) (h : σ.symm x = x) : σ x = x := by + have h2 := congrArg σ h + rw [Equiv.apply_symm_apply] at h2 + exact h2.symm + +/-- **G2, TAIL case.** Hypotheses (AUDIT2): helpers end identity; G0-members are born at 0; the V-enders +(= the helpers ending at the single chart `d`) are exactly V ⊆ H; σ permutes helpers only; hub gauge +L ∈ Blk(V'), M ∈ Blk(G0) with V' = σ⁻¹ V. Then the (birth,end) multiset is unchanged. -/ +theorem tail_pairs {H V G0 : Reg → Prop} [DecidablePred H] [DecidablePred V] + {F : Matrix Reg Reg K} (hF : HelpersId H F) (σ : Equiv.Perm Reg) (hσ : ∀ x, ¬ H x → σ x = x) + (hVH : ∀ x, V x → H x) (hE : ∀ x, H x → (ε x = d ↔ V x)) (hG : ∀ x, G0 x → β x = 0) + (hu : Undo (fun x => V (σ x)) G0 F (rowSw σ F)) : + pairsTail β ε σ (Finset.univ.filter H) = pairs β ε (Finset.univ.filter H) := by + classical + have hσH := sigma_H σ hσ + have hσs : ∀ x, ¬ H x → σ.symm x = x := fun x hx => (Equiv.symm_apply_eq σ).2 (hσ x hx).symm + have hσsH := sigma_H σ.symm hσs + set Hs : Finset Reg := Finset.univ.filter H with hHs + have memH : ∀ x, x ∈ Hs ↔ H x := by intro x; simp [hHs] + have F1 : ∀ x, H x → ¬ V (σ x) → σ x ≠ x → β x = 0 ∧ β (σ x) = 0 := by + intro x hx hv hm + obtain ⟨a, b⟩ := tail_force hF σ hσH hu hx hv hm + exact ⟨hG _ a, hG _ b⟩ + have F2 : ∀ x, H x → ¬ V (σ x) → β (σ x) = β x := by + intro x hx hv + by_cases hm : σ x = x + · rw [hm] + · obtain ⟨a, b⟩ := F1 x hx hv hm; rw [a, b] + set V' : Finset Reg := Hs.filter (fun x => V (σ x)) with hV' + set Vf : Finset Reg := Hs.filter V with hVf + have hcard : V'.card = Vf.card := by + apply Finset.card_bij (fun x _ => σ x) + · intro x hx + simp only [hV', hVf, Finset.mem_filter, memH] at hx ⊢ + exact ⟨hσH x hx.1, hx.2⟩ + · intro x _ y _ e; exact σ.injective e + · intro y hy + simp only [hV', hVf, Finset.mem_filter, memH] at hy ⊢ + refine ⟨σ.symm y, ⟨hσsH y hy.1, by simpa using hy.2⟩, by simp⟩ + have F4 : ∀ x ∈ V', x ∉ Vf → β x = 0 := by + intro x hx hxn + simp only [hV', hVf, Finset.mem_filter, memH] at hx hxn + have hnV : ¬ V x := fun h => hxn ⟨hx.1, h⟩ + have hmu : σ (σ.symm x) ≠ σ.symm x := by + intro e + rw [Equiv.apply_symm_apply] at e + exact hnV (by have := symm_fix σ x e.symm; rw [← this]; exact hx.2) + have := (F1 _ (hσsH x hx.1) (by rw [Equiv.apply_symm_apply]; exact hnV) hmu).2 + rwa [Equiv.apply_symm_apply] at this + have F5 : ∀ y ∈ Vf, y ∉ V' → β y = 0 := by + intro y hy hyn + simp only [hV', hVf, Finset.mem_filter, memH] at hy hyn + have hnV : ¬ V (σ y) := fun h => hyn ⟨hy.1, h⟩ + have hm : σ y ≠ y := fun e => hnV (by rw [e]; exact hy.2) + exact (F1 y hy.1 hnV hm).1 + have hV'map : V'.val.map β = Vf.val.map β := + map_birth_eq β V' Vf hcard F4 F5 + -- the non-V' part is carried to the non-V part by σ + set N1 : Finset Reg := Hs.filter (fun x => ¬ V (σ x)) with hN1 + set N2 : Finset Reg := Hs.filter (fun x => ¬ V x) with hN2 + have hN : N2 = N1.map σ.toEmbedding := by + ext y + simp only [hN1, hN2, Finset.mem_filter, Finset.mem_map, memH, Equiv.coe_toEmbedding] + constructor + · rintro ⟨hy, hv⟩ + exact ⟨σ.symm y, ⟨hσsH y hy, by simpa using hv⟩, by simp⟩ + · rintro ⟨x, ⟨hx, hv⟩, rfl⟩ + exact ⟨hσH x hx, hv⟩ + unfold pairsTail pairs + rw [split_map Hs.val (fun x => V (σ x)), split_map Hs.val V] + congr 1 + · have e1 : (Hs.val.filter (fun x => V (σ x))).map (fun x => (β x, ε (σ x))) = + V'.val.map (fun x => (β x, d)) := by + apply Multiset.map_congr rfl + intro x hx + have hx' : x ∈ V' := hx + simp only [hV', Finset.mem_filter, memH] at hx' + rw [(hE (σ x) (hσH x hx'.1)).2 hx'.2] + have e2 : (Hs.val.filter V).map (fun x => (β x, ε x)) = Vf.val.map (fun x => (β x, d)) := by + apply Multiset.map_congr rfl + intro x hx + have hx' : x ∈ Vf := hx + simp only [hVf, Finset.mem_filter, memH] at hx' + rw [(hE x hx'.1).2 hx'.2] + rw [e1, e2] + have h3 : ∀ A : Finset Reg, A.val.map (fun x => (β x, d)) = (A.val.map β).map (fun b => (b, d)) := by + intro A; rw [Multiset.map_map]; rfl + rw [h3, h3, hV'map] + · have e : (Hs.val.filter (fun x => ¬ V (σ x))) = N1.val := rfl + have e' : (Hs.val.filter (fun x => ¬ V x)) = N2.val := rfl + rw [e, e', hN, Finset.map_val, Multiset.map_map] + apply Multiset.map_congr rfl + intro x hx + have hx' : x ∈ N1 := hx + simp only [hN1, Finset.mem_filter, memH] at hx' + simp [F2 x hx'.1 hx'.2] + +/-- **G2, HEAD case, proved directly** (no time reversal). A head relabel x ↦ birth of σ x, same end; +the hub undoing it is L ∈ Blk(V) (the V-enders are unchanged) and the prefix M ∈ Blk(G1), where G1 is the set +of helpers born at 0 in the NEW word (`G1 x → β (σ x) = 0`; the head-side analogue of V' = σ⁻¹ V). -/ +theorem head_pairs {H V G1 : Reg → Prop} [DecidablePred H] [DecidablePred V] + {F : Matrix Reg Reg K} (hF : HelpersId H F) (σ : Equiv.Perm Reg) (hσ : ∀ x, ¬ H x → σ x = x) + (hVH : ∀ x, V x → H x) (hE : ∀ x, H x → (ε x = d ↔ V x)) (hG : ∀ x, G1 x → β (σ x) = 0) + (hu : Undo V G1 F (colSw σ F)) : + pairsHead β ε σ (Finset.univ.filter H) = pairs β ε (Finset.univ.filter H) := by + classical + have hσH := sigma_H σ hσ + have hσs : ∀ x, ¬ H x → σ.symm x = x := fun x hx => (Equiv.symm_apply_eq σ).2 (hσ x hx).symm + have hσsH := sigma_H σ.symm hσs + set Hs : Finset Reg := Finset.univ.filter H with hHs + have memH : ∀ x, x ∈ Hs ↔ H x := by intro x; simp [hHs] + have F1 : ∀ x, H x → ¬ V x → σ x ≠ x → β x = 0 ∧ β (σ x) = 0 := by + intro x hx hv hm + obtain ⟨a, b⟩ := head_force hF σ hu hx hv hm + refine ⟨?_, hG _ b⟩ + have := hG _ a + rwa [Equiv.apply_symm_apply] at this + have F2 : ∀ x, H x → ¬ V x → β (σ x) = β x := by + intro x hx hv + by_cases hm : σ x = x + · rw [hm] + · obtain ⟨a, b⟩ := F1 x hx hv hm; rw [a, b] + set Vf : Finset Reg := Hs.filter V with hVf + set Vs : Finset Reg := Vf.map σ.toEmbedding with hVs + have hcard : Vs.card = Vf.card := Finset.card_map _ + have F4 : ∀ x ∈ Vs, x ∉ Vf → β x = 0 := by + intro x hx hxn + simp only [hVs, hVf, Finset.mem_map, Finset.mem_filter, memH, Equiv.coe_toEmbedding] at hx hxn + obtain ⟨w, ⟨hw, hv⟩, rfl⟩ := hx + have hnV : ¬ V (σ w) := fun h => hxn ⟨hσH w hw, h⟩ + have hm : σ (σ w) ≠ σ w := fun e => hnV (by have := σ.injective e; rw [this]; exact hv) + exact (F1 (σ w) (hσH w hw) hnV hm).1 + have F5 : ∀ x ∈ Vf, x ∉ Vs → β x = 0 := by + intro x hx hxn + simp only [hVs, hVf, Finset.mem_map, Finset.mem_filter, memH, Equiv.coe_toEmbedding] at hx hxn + have hnV : ¬ V (σ.symm x) := fun h => hxn ⟨σ.symm x, ⟨hσsH x hx.1, h⟩, by simp⟩ + have hm : σ (σ.symm x) ≠ σ.symm x := by + intro e + rw [Equiv.apply_symm_apply] at e + exact hnV (by rw [← e]; exact hx.2) + have := (F1 (σ.symm x) (hσsH x hx.1) hnV hm).2 + rwa [Equiv.apply_symm_apply] at this + have hmap : Vs.val.map β = Vf.val.map β := map_birth_eq β Vs Vf hcard F4 F5 + unfold pairsHead pairs + rw [split_map Hs.val V] + conv_rhs => rw [split_map Hs.val V] + congr 1 + · have e1 : (Hs.val.filter V).map (fun x => (β (σ x), ε x)) = Vf.val.map (fun x => (β (σ x), d)) := by + apply Multiset.map_congr rfl + intro x hx + have hx' : x ∈ Vf := hx + simp only [hVf, Finset.mem_filter, memH] at hx' + rw [(hE x hx'.1).2 hx'.2] + have e2 : (Hs.val.filter V).map (fun x => (β x, ε x)) = Vf.val.map (fun x => (β x, d)) := by + apply Multiset.map_congr rfl + intro x hx + have hx' : x ∈ Vf := hx + simp only [hVf, Finset.mem_filter, memH] at hx' + rw [(hE x hx'.1).2 hx'.2] + rw [e1, e2] + have h3 : Vf.val.map (fun x => (β (σ x), d)) = (Vs.val.map β).map (fun b => (b, d)) := by + rw [hVs, Finset.map_val, Multiset.map_map, Multiset.map_map]; rfl + have h4 : Vf.val.map (fun x => (β x, d)) = (Vf.val.map β).map (fun b => (b, d)) := by + rw [Multiset.map_map]; rfl + rw [h3, h4, hmap] + · have e' : (Hs.val.filter (fun x => ¬ V x)) = (Hs.filter (fun x => ¬ V x)).val := rfl + rw [e'] + apply Multiset.map_congr rfl + intro x hx + have hx' : x ∈ Hs.filter (fun x => ¬ V x) := hx + simp only [Finset.mem_filter, memH] at hx' + simp [F2 x hx'.1 hx'.2] + +/-! ### G2 ⇒ Π ⇒ F: the combined statement -/ + +theorem tail_Pi {H V G0 : Reg → Prop} [DecidablePred H] [DecidablePred V] + {F : Matrix Reg Reg K} (hF : HelpersId H F) (σ : Equiv.Perm Reg) (hσ : ∀ x, ¬ H x → σ x = x) + (hVH : ∀ x, V x → H x) (hE : ∀ x, H x → (ε x = d ↔ V x)) (hG : ∀ x, G0 x → β x = 0) + (hu : Undo (fun x => V (σ x)) G0 F (rowSw σ F)) : + PiOf (pairsTail β ε σ (Finset.univ.filter H)) = PiOf (pairs β ε (Finset.univ.filter H)) := by + rw [tail_pairs β ε d hF σ hσ hVH hE hG hu] + +theorem head_Pi {H V G1 : Reg → Prop} [DecidablePred H] [DecidablePred V] + {F : Matrix Reg Reg K} (hF : HelpersId H F) (σ : Equiv.Perm Reg) (hσ : ∀ x, ¬ H x → σ x = x) + (hVH : ∀ x, V x → H x) (hE : ∀ x, H x → (ε x = d ↔ V x)) (hG : ∀ x, G1 x → β (σ x) = 0) + (hu : Undo V G1 F (colSw σ F)) : + PiOf (pairsHead β ε σ (Finset.univ.filter H)) = PiOf (pairs β ε (Finset.univ.filter H)) := by + rw [head_pairs β ε d hF σ hσ hVH hE hG hu] + +/-- G2 + K: a hub-undoable pure tail relabel that keeps the step multiset S (SwapNull.stays_multiset) leaves +F(t), hence κ, unchanged. -/ +theorem tail_F_null {H V G0 : Reg → Prop} [DecidablePred H] [DecidablePred V] + {F : Matrix Reg Reg K} (hF : HelpersId H F) (σ : Equiv.Perm Reg) (hσ : ∀ x, ¬ H x → σ x = x) + (hVH : ∀ x, V x → H x) (hE : ∀ x, H x → (ε x = d ↔ V x)) (hG : ∀ x, G0 x → β x = 0) + (hu : Undo (fun x => V (σ x)) G0 F (rowSw σ F)) + (E : Inv) (tb : Table) (S : Multiset (ℕ × ℕ)) (t : ℝ) : + FK E tb S (PiOf (pairsTail β ε σ (Finset.univ.filter H))) t = + FK E tb S (PiOf (pairs β ε (Finset.univ.filter H))) t := by + rw [tail_Pi β ε d hF σ hσ hVH hE hG hu] + +theorem head_F_null {H V G1 : Reg → Prop} [DecidablePred H] [DecidablePred V] + {F : Matrix Reg Reg K} (hF : HelpersId H F) (σ : Equiv.Perm Reg) (hσ : ∀ x, ¬ H x → σ x = x) + (hVH : ∀ x, V x → H x) (hE : ∀ x, H x → (ε x = d ↔ V x)) (hG : ∀ x, G1 x → β (σ x) = 0) + (hu : Undo V G1 F (colSw σ F)) + (E : Inv) (tb : Table) (S : Multiset (ℕ × ℕ)) (t : ℝ) : + FK E tb S (PiOf (pairsHead β ε σ (Finset.univ.filter H))) t = + FK E tb S (PiOf (pairs β ε (Finset.univ.filter H))) t := by + rw [head_Pi β ε d hF σ hσ hVH hE hG hu] + +end Pairs + +/-! ### C3 (R1's 3-cycle) is NOT undoable once V' = σ⁻¹ V is used (Lean check of AUDIT2's observation) -/ +section C3 +open SwapNull + +/-- a = (5→9), b = (0→7), c = (0→9) on Fin 3; σ: a ↦ b, b ↦ c, c ↦ a. -/ +def c3β : Fin 3 → ℕ := ![5, 0, 0] +def c3ε : Fin 3 → ℕ := ![9, 7, 9] +def c3σ : Equiv.Perm (Fin 3) := Equiv.swap 0 1 * Equiv.swap 1 2 + +theorem c3σ_apply : c3σ 0 = 1 ∧ c3σ 1 = 2 ∧ c3σ 2 = 0 := by decide + +/-- the pair multiset changes (Π {4,7,9} → {2,9,9} in R1's words) -/ +theorem c3_pairs_change : + pairsTail c3β c3ε c3σ Finset.univ ≠ pairs c3β c3ε Finset.univ := by decide + +theorem c3_not_undoable (G0 : Fin 3 → Prop) (hG : ∀ x, G0 x → c3β x = 0) : + ¬ Undo (fun x => (c3ε (c3σ x) = 9 : Prop)) G0 (1 : Matrix (Fin 3) (Fin 3) ℚ) + (rowSw c3σ 1) := by + intro hu + have := tail_pairs (K := ℚ) (H := fun _ => True) (V := fun x => c3ε x = 9) c3β c3ε 9 + (F := 1) (fun _ _ _ => rfl) c3σ (fun x hx => absurd trivial hx) (fun _ _ => trivial) + (fun x _ => Iff.rfl) hG hu + have h2 : (Finset.univ.filter (fun _ : Fin 3 => True)) = (Finset.univ : Finset (Fin 3)) := by simp + rw [h2] at this + exact c3_pairs_change this +end C3 + +#print axioms K_word +#print axioms K_congr +#print axioms K_invoice +#print axioms kappa_depends_only +#print axioms d0_native +#print axioms tail_force +#print axioms head_force +#print axioms tail_pairs +#print axioms head_pairs +#print axioms tail_F_null +#print axioms head_F_null +#print axioms c3_not_undoable + +end G2 + +end FibreK diff --git a/research/p104-tiered-ceiling/lean/Nov15/FibreK.md b/research/p104-tiered-ceiling/lean/Nov15/FibreK.md new file mode 100644 index 0000000000..eaeb3e7e8e --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/FibreK.md @@ -0,0 +1,51 @@ +# FibreK (Nov 17): Theorem K and G2 for pure relabels, in Lean + +`Nov15/FibreK.lean`, Lean 4.33.0-rc1 + Mathlib, kernel only: no `sorry`, no `native_decide`; every theorem prints +`[propext, Classical.choice, Quot.sound]`. Builds in 10 s / 2.9 GB (runlean.sh guard). Reuses `SwapNull` (Blk, Undo, rowSw, +colSw; olean built into .lake/build/lib/lean/Nov15) and `CallerCost` (Hist, Inv, invoice, Dh/Dinv). + +## 1. THEOREM K (AUDIT2: sound with fixes) +P0 is an explicit hypothesis: `Table {tT tP : ℕ → Hist}` = the ranks a helper pays on T for climb d = e - b and on P for a +helper MOVE of |Δdim| = d (the price checker's per-call ranks; AUDIT2 could not find the README in the tree, so the table is a parameter, +not a quoted constant). A word is `E : Inv` (fixed by the ends) plus helpers `{b, e, steps}`. +* `K_word`: `Fi (nativeInv E tb H) t = FK E tb (Ssum H) (PiW H) t`, i.e. F(t) = Σ_r (T_r − P_r) r^(1−t) is a function of + (E, S = multiset of helper MOVEs (src dim, tgt dim), Π = multiset {e_h − b_h}). Births/ends enter only through Π; ADD/SCALE/SWAP + appear nowhere (they are not in the table). +* `K_congr`, `kappa_depends_only`: same (E, S, Π) ⇒ same F, same roots, also for the caller invoice + `K_invoice : Fi (invoice c n L) t = Fi c t + L · FK E tb S Π t` (CallerCost.invoice). +* `d0_native`: for `d0Table` (ranks = gaps) the helper part is Σ_h [f(e−b) − Σ_steps f(gap)] (the per-helper D0 identity of + FloorD0/V2Bridge, f = r ln r, Dh convention). +Remark: the dependence on S is only through the multiset of GAPS |Δdim|; the source dim itself is not priced. + +## 2. G2 for PURE relabels (AUDIT2: sound with fixes) +Model: registers `Reg` (Fintype), final matrix `F : Matrix Reg Reg K`; `HelpersId H F` = every helper's final row is its own unit +vector; hub gauge = `Undo V G F F'` := ∃ L M, Blk V L ∧ Blk G M ∧ L·F'·M = F (SwapNull; invertibility NOT demanded, which only +strengthens the conclusions). σ permutes helpers only (`σ x = x` off H). β, ε : birth/end dims; V ⊆ H = the helpers with ε = d +(one chart, `hE : ε x = d ↔ V x`). +* `tail_force`: F' = rowSw σ F (SwapNull.tail_run), L ∈ Blk(V′), M ∈ Blk(G0) ⇒ every moved helper x ∉ V′ has x, σ x ∈ G0. +* `tail_pairs`: with G0 ⊆ {β = 0} and **V′ = σ⁻¹ V** (`fun x => V (σ x)`), the (birth,end) multiset {(β x, ε (σ x))} equals + {(β x, ε x)}. Proof: σ carries H∖V′ onto H∖V keeping β (moved ⇒ both birth 0); V′∖V and V∖V′ are birth-0 and |V′| = |V| + (`map_birth_eq`). +* `head_force`, `head_pairs`, DIRECT (not by time reversal): F' = colSw σ F (SwapNull.head_run), L ∈ Blk(V) (V unchanged), M ∈ Blk(G1) + where **G1 is the NEW births-at-0 set** (`G1 x → β (σ x) = 0`); moved x ∉ V ⇒ σ⁻¹x, x ∈ G1 ⇒ β x = β (σ x) = 0. Pair multiset + {(β (σ x), ε x)} = {(β x, ε x)}. This is the head analogue of V′ = σ⁻¹V (the time-reversal image of "prefix ↔ V"); using the + native G0 here is the head-side form of R1's slip. +* `tail_Pi`, `head_Pi`: Π unchanged. `tail_F_null`, `head_F_null`: FK (hence F(t), hence κ by K) unchanged, for any S, E, tb. S + being unchanged by a swap is SwapNull.stays_multiset (not re-proved; the theorem takes S as the common argument). +* `c3_not_undoable`: Lean check of AUDIT2's observation. R1's 3-cycle C3 (a=(5→9), b=(0→7), c=(0→9), σ: a→b→c→a, identity F) + is NOT undoable under V′ = σ⁻¹V for any G0 ⊆ {β=0}: its pair multiset changes (`c3_pairs_change`), which `tail_pairs` forbids + for undoable relabels. (Undoable only under the native V = the retracted slip.) + +No paper statement was found false as written. Corrections to the wording: (i) heads need the NEW G0 (G1 above), "same proof under +time reversal" is right only with that substitution; (ii) K needs P0 as a stated table; (iii) G2 conclusions about κ also need +S unchanged (SwapNull.stays_multiset), which is a separate hypothesis here. + +## 3. NOT covered +* relabel + interior gauge D(t) jointly (D(end) ≠ I on helper rows; AUDIT2 item 2/4): the model has D = I, F' = P_σ F exactly. +* the LOOP claim (THEORY2 §2 "interiors differ by a time-slice gauge, κ-null"): UNSOUND as stated (D(t) = U′U⁻¹ exists for any two + circuits; legality of D(t+1) T D(t)⁻¹ and D(end) = I are the content). Not formalised; only the true restatement + "same skeleton ⇒ κ-null" follows from K_word (S and Π fixed). +* "native = max over fibre": NOT established (needs the joint case above, theorem R with the real the price checker concavity, and S that + includes END charts for D helpers). R (re-pairing monotonicity), G1-tree, T (cover lemma), U in full generality are not formalised. +* mixed head+tail sequences (only each pure case); multi-chart V ends; helpers not ending identity. +* The real the price checker table values are not instantiated (`Table` is abstract; `d0Table` is the D0 convention). diff --git a/research/p104-tiered-ceiling/lean/Nov15/FrameSep.lean b/research/p104-tiered-ceiling/lean/Nov15/FrameSep.lean new file mode 100644 index 0000000000..abf460717d --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/FrameSep.lean @@ -0,0 +1,165 @@ +/- +SPEC7/SPEC8 frame-separation law, See FrameSep.md. +Source: internal notes (sec 2, 4), SPEC8.md (sec 2, 4). +Abstract model: frames = submodules of V; a route is a time-indexed frame sequence whose +non-owned (public) steps ascend by inclusion; owned steps are arbitrary. +-/ +import Mathlib.LinearAlgebra.Span.Basic +import Mathlib.Algebra.Field.Rat +import Mathlib.Data.Rat.Defs + +namespace FrameSep + +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] + +/-- A register's frame history; `owned t` marks step t -> t+1 as an owned MOVE. -/ +structure Route (K V : Type*) [Field K] [AddCommGroup V] [Module K V] where + f : ℕ → Submodule K V + owned : ℕ → Prop + pub : ∀ t, ¬ owned t → f t ≤ f (t + 1) + +namespace Route +variable (R : Route K V) + +/-- public stretch: no owned step in [a,b) -/ +def Pub (a b : ℕ) : Prop := ∀ s, a ≤ s → s < b → ¬ R.owned s + +theorem pub_mono {a b : ℕ} (hab : a ≤ b) (h : R.Pub a b) : R.f a ≤ R.f b := by + induction b, hab using Nat.le_induction with + | base => exact le_rfl + | succ b hb ih => + exact (ih fun s h1 h2 => h s h1 (by omega)).trans (R.pub b (h b hb (by omega))) + +theorem persist {u : V} {a b : ℕ} (hab : a ≤ b) (h : R.Pub a b) (hu : u ∈ R.f a) : + u ∈ R.f b := R.pub_mono hab h hu + +/-- First-exit law: leaving a u-containing frame needs an OWNED step that genuinely drops u. -/ +theorem exit_owned {u : V} {a b : ℕ} (hab : a ≤ b) (hu : u ∈ R.f a) (hb : u ∉ R.f b) : + ∃ s, a ≤ s ∧ s < b ∧ R.owned s ∧ u ∈ R.f s ∧ u ∉ R.f (s + 1) := by + induction b, hab using Nat.le_induction with + | base => exact absurd hu hb + | succ b hb' ih => + by_cases hb0 : u ∈ R.f b + · refine ⟨b, hb', by omega, ?_, hb0, hb⟩ + by_contra hno + exact hb (R.pub b hno hb0) + · obtain ⟨s, h1, h2, h3, h4, h5⟩ := ih hb0 + exact ⟨s, h1, by omega, h3, h4, h5⟩ + +/-- A route is public if it has no owned steps. -/ +def IsPublic : Prop := ∀ t, ¬ R.owned t + +theorem IsPublic.mono {R : Route K V} (h : R.IsPublic) {a b : ℕ} (hab : a ≤ b) : + R.f a ≤ R.f b := R.pub_mono hab fun s _ _ => h s + +theorem IsPublic.persist {R : Route K V} (h : R.IsPublic) {u : V} {a b : ℕ} (hab : a ≤ b) + (hu : u ∈ R.f a) : u ∈ R.f b := h.mono hab hu + +end Route + +/-- SPEC7 core: X contains u at the start of a public route, Y's frames lie in W with u ∉ W. + Then X's frames never equal Y's frames. -/ +theorem X_Y_never_share (X Y : Route K V) (u : V) (W : Submodule K V) (hu : u ∉ W) + (hX : X.IsPublic) (hX0 : u ∈ X.f 0) (hY : ∀ t, Y.f t ≤ W) (s t : ℕ) : + X.f s ≠ Y.f t := by + intro h + exact hu (hY t (h ▸ hX.persist (Nat.zero_le s) hX0)) + +/-- Any public register that has read X_a (co-present at X's frame, X's frame containing u) + at time t0 never again shares a frame with Y at any time t ≥ t0. -/ +theorem reader_never_meets_Y_after (X Y P : Route K V) (u : V) (W : Submodule K V) + (hu : u ∉ W) (hX : X.IsPublic) (hX0 : u ∈ X.f 0) (hP : P.IsPublic) + (hY : ∀ t, Y.f t ≤ W) {s t0 : ℕ} (hread : P.f t0 = X.f s) {t t' : ℕ} (htt : t0 ≤ t) : + P.f t ≠ Y.f t' := by + intro h + have h1 : u ∈ P.f t0 := hread ▸ hX.persist (Nat.zero_le s) hX0 + exact hu (hY t' (h ▸ hP.persist htt h1)) + +/-- Scope: "ever reads X_a ⇒ never meets Y_a" needs "afterwards"; a public helper may meet Y + before it reads X. Concrete counterexample over ℚ×ℚ. -/ +theorem meet_before_read_possible : + ∃ (X Y P : Route ℚ (ℚ × ℚ)) (u : ℚ × ℚ) (W : Submodule ℚ (ℚ × ℚ)), + u ∉ W ∧ X.IsPublic ∧ u ∈ X.f 0 ∧ P.IsPublic ∧ (∀ t, Y.f t ≤ W) ∧ + P.f 1 = X.f 1 ∧ P.f 0 = Y.f 0 := by + let W : Submodule ℚ (ℚ × ℚ) := Submodule.span ℚ {((0 : ℚ), (1 : ℚ))} + refine ⟨⟨fun _ => ⊤, fun _ => False, fun _ _ => le_rfl⟩, + ⟨fun _ => W, fun _ => False, fun _ _ => le_rfl⟩, + ⟨fun t => if t = 0 then W else ⊤, fun _ => False, ?_⟩, (1, 0), W, ?_, ?_, ?_, ?_, ?_, ?_, ?_⟩ + · intro t _ + by_cases h : t = 0 + · subst h; simp + · simp [h] + · intro h + obtain ⟨a, ha⟩ := Submodule.mem_span_singleton.mp h + have := congrArg Prod.fst ha + simp at this + · intro t h; exact h + · trivial + · intro t h; exact h + · intro t; exact le_rfl + · simp + · simp + +/-- Entry law: content (u) in a register's history, then a u-free frame at time t: + an owned step dropped it. With all owned destinations in D and F = frame(t) ∉ D, + the register took an owned MOVE to a landing frame d ∈ D and then ASCENDED + publicly (d < F strictly) before reaching F. -/ +theorem owned_landing_then_ascent (R : Route K V) (D : Set (Submodule K V)) (u : V) + (hD : ∀ s, R.owned s → R.f (s + 1) ∈ D) {a t : ℕ} (hat : a ≤ t) (hu : u ∈ R.f a) + (hF : u ∉ R.f t) (hFD : R.f t ∉ D) : + ∃ s, a ≤ s ∧ s < t ∧ R.owned s ∧ R.f (s + 1) ∈ D ∧ R.f (s + 1) < R.f t := by + -- last owned step before t + have key : ∀ t, a ≤ t → R.Pub a t ∨ + ∃ s, a ≤ s ∧ s < t ∧ R.owned s ∧ R.f (s + 1) ≤ R.f t := by + intro t hat + induction t, hat using Nat.le_induction with + | base => exact Or.inl fun s h1 h2 => by omega + | succ t ht ih => + by_cases ho : R.owned t + · exact Or.inr ⟨t, ht, by omega, ho, le_rfl⟩ + · rcases ih with h | ⟨s, h1, h2, h3, h4⟩ + · left + intro s h1 h2 + by_cases hs : s = t + · subst hs; exact ho + · exact h s h1 (by omega) + · exact Or.inr ⟨s, h1, by omega, h3, h4.trans (R.pub t ho)⟩ + rcases key t hat with h | ⟨s, h1, h2, h3, h4⟩ + · exact absurd (R.persist hat h hu) hF + · refine ⟨s, h1, h2, h3, hD s h3, lt_of_le_of_ne h4 ?_⟩ + intro heq + exact hFD (heq ▸ hD s h3) + +/-- SPEC8 corollary: a u-holding register sitting in Y's final frame F (u-free since F ≤ W, + u ∉ W) with F ∉ D has landed by an owned MOVE in D and climbed publicly strictly above + the landing frame: it is a ferrying register, not an owned register at a landing frame. -/ +theorem delivery_needs_ferry (R : Route K V) (D : Set (Submodule K V)) (u : V) + (W F : Submodule K V) (hu : u ∉ W) (hFW : F ≤ W) (hFD : F ∉ D) + (hD : ∀ s, R.owned s → R.f (s + 1) ∈ D) {a t : ℕ} (hat : a ≤ t) (hua : u ∈ R.f a) + (hFt : R.f t = F) : + ∃ s, a ≤ s ∧ s < t ∧ R.owned s ∧ R.f (s + 1) ∈ D ∧ R.f (s + 1) < F := by + have hF : u ∉ R.f t := fun h => hu (hFW (hFt ▸ h)) + obtain ⟨s, h1, h2, h3, h4, h5⟩ := + owned_landing_then_ascent R D u hD hat hua hF (hFt ▸ hFD) + exact ⟨s, h1, h2, h3, h4, hFt ▸ h5⟩ + +/-- Consequently no owned destination (a fixed set D) equals a delivered frame: + strict ascent means the delivering register took at least one public step after its + owned landing (landing frame ≠ F). -/ +theorem landing_ne_final (R : Route K V) (D : Set (Submodule K V)) (u : V) + (W F : Submodule K V) (hu : u ∉ W) (hFW : F ≤ W) (hFD : F ∉ D) + (hD : ∀ s, R.owned s → R.f (s + 1) ∈ D) {a t : ℕ} (hat : a ≤ t) (hua : u ∈ R.f a) + (hFt : R.f t = F) : + ∃ s, s < t ∧ R.owned s ∧ R.f (s + 1) ≠ F := by + obtain ⟨s, -, h2, h3, -, h5⟩ := delivery_needs_ferry R D u W F hu hFW hFD hD hat hua hFt + exact ⟨s, h2, h3, h5.ne⟩ + +end FrameSep + +#print axioms FrameSep.X_Y_never_share +#print axioms FrameSep.reader_never_meets_Y_after +#print axioms FrameSep.meet_before_read_possible +#print axioms FrameSep.Route.exit_owned +#print axioms FrameSep.owned_landing_then_ascent +#print axioms FrameSep.delivery_needs_ferry +#print axioms FrameSep.landing_ne_final diff --git a/research/p104-tiered-ceiling/lean/Nov15/FrameSep.md b/research/p104-tiered-ceiling/lean/Nov15/FrameSep.md new file mode 100644 index 0000000000..16dbbd840e --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/FrameSep.md @@ -0,0 +1,13 @@ +# FrameSep.lean: SPEC7 frame-separation law + SPEC8 corollary +Kernel-only, no sorry/native_decide, ~3 s / 1.5 GB, imports Mathlib only (does not need TokenCancel/TCLemma/W0Cancel: the law is purely about frames). Axioms [propext, Classical.choice, Quot.sound] (two theorems: [propext, Quot.sound]). + +**Model.** Frames = submodules of V. `Route`: frame sequence f, flag `owned t` for step t->t+1; non-owned (public) steps satisfy f t <= f (t+1); owned steps arbitrary. "Holds x_a content" = frame contains u_a. + +**Theorems.** +- `Route.exit_owned`: u in f a, u not in f b (a<=b) => an OWNED step s with u in f s, u not in f (s+1). (public routes never drop u.) +- `X_Y_never_share`: X public with u in f 0, Y frames <= W, u not in W => X.f s != Y.f t for all s,t (SPEC7 core; "below V" is automatic since W != V). +- `reader_never_meets_Y_after`: public P co-present with X at t0 => P.f t != Y.f t' for all t >= t0. +- `owned_landing_then_ascent`, `delivery_needs_ferry`, `landing_ne_final` (SPEC8): all owned MOVE destinations in D, F = Y's final frame (F <= W), F not in D, a register that ever held u sits in F at t => it took an owned MOVE to some d in D and climbed publicly with d < F strictly, i.e. it is a ferrying register, never an owned register at its landing frame. + +**Scope / correction (stated at once).** SPEC7's "any public that ever reads X_a can never meet Y_a" is true only AFTER the read (its parenthetical "later frames contain u_a"). `meet_before_read_possible` (over Q x Q): a public helper has frame W = Y's frame at time 0, then reads X at time 1. The paper statement is not false (it says later), but the unqualified reading is; use the `_after` form. +Modelling limits: content is tracked by "frame contained u" along one register's history (direct holders; multi-hop taint through u-free registers not modelled); owned steps are assumed to land in D (every owned step is a MOVE with destination in D); CLEAR of content is not modelled. diff --git a/research/p104-tiered-ceiling/lean/Nov15/JointCeiling.lean b/research/p104-tiered-ceiling/lean/Nov15/JointCeiling.lean new file mode 100644 index 0000000000..4989827790 --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/JointCeiling.lean @@ -0,0 +1,809 @@ +/- +JOINT-CEILING (; CORRECTED by , Nov 17 per CALLERFLOOR R2 + AUDIT2: arms of 1 repriced). Formalises the AUDITED structure of CALLERFLOOR R1 (internal notes + AUDIT1.md) +on top of Nov15/CallerCost.lean. Kernel only (no sorry, no native_decide; `decide +kernel` is kernel evaluation, no extra axiom). +F(s) = sum (T-P) r^s, s = 1-t (so F = the R1 "F(t)" = sum (T-P) r^(1-t)). + 1. invoice F = caller F + k * native F for ALL s (invoice_F, same proof as D0). + 2. native floor Nfl(s) = 400*8^s + 16 + 88*(2-2^s): the exact F of the floor histogram (natFloor_F); the bound F_nat <= -Nfl is a HYPOTHESIS (hN). + 3. class lemmas as HYPOTHESES (structure InClass): B-form per-split optimality pointwise in F, sign floor th >= 4 (or 3), two arms (rho = 2). + 4. closed form FB a b th (all a,b >= 1) with bridge to CallerCost.caller for a,b >= 2 (FB_eq). + 5. ceiling theorem, REDUCED to the named numeric hypothesis NumCert th tbar (finite list of rational inequalities, tail.py). + 6. kernel-checked numerics: split 2|2 at t >= 141/4096, the CORRECTED argmax split 1|1 at t >= 176/4096 (36 rational cells), and the control C(8|9): root of the invoice F in (.0204,.0205). + CORRECTION (R2/AUDIT2): R1's FB overcharged every arm of length 1 by 208 one-stage lines (P[8]) -- FBc below adds 208*8^s per arm of 1; + the old .0336 ceiling (and the NumCert built from cf.py) is WITHDRAWN; the certified ceiling is kappa <= .0419448764 (A = 4 QUERY, B-form masks, peak 1|1). +-/ +import Nov15.CallerCost +import Mathlib.Analysis.SpecialFunctions.Pow.Real + +namespace JointCeiling +open CallerCost Real + +/-! ### 1. F-form of the invoice -/ +noncomputable def Fh (s : ℝ) (l : Hist) : ℝ := (l.map fun p => (p.2 : ℝ) * (p.1 : ℝ) ^ s).sum +noncomputable def Finv (s : ℝ) (i : Inv) : ℝ := Fh s i.T - Fh s i.P + +theorem Fh_append (s : ℝ) (l m : Hist) : Fh s (l ++ m) = Fh s l + Fh s m := by simp [Fh] +theorem Fh_scale (s : ℝ) (L : ℕ) (l : Hist) : Fh s (scale L l) = L * Fh s l := by + induction l with + | nil => simp [Fh, scale] + | cons p l ih => + simp only [Fh, scale, List.map_cons, List.sum_cons] at ih ⊢ + rw [ih]; push_cast; ring + +/-- the invoice in kappa form: F = caller part + k * native part, for every s (hence every t = 1 - s) -/ +theorem invoice_F (s : ℝ) (c n : Inv) (L : ℕ) : Finv s (invoice c n L) = Finv s c + L * Finv s n := by + simp only [Finv, invoice, Fh_append, Fh_scale]; ring + +theorem Fh_mono (l : Hist) (hl : ∀ p ∈ l, 1 ≤ p.1) {s s' : ℝ} (h : s ≤ s') : Fh s l ≤ Fh s' l := by + induction l with + | nil => simp [Fh] + | cons p l ih => + have ih' := ih (fun q hq => hl q (by simp [hq])) + have hp : (1 : ℝ) ≤ p.1 := by exact_mod_cast hl p (by simp) + simp only [Fh, List.map_cons, List.sum_cons] at ih' ⊢ + have := Real.rpow_le_rpow_of_exponent_le hp h + have h2 : (p.2 : ℝ) * (p.1 : ℝ) ^ s ≤ (p.2 : ℝ) * (p.1 : ℝ) ^ s' := + mul_le_mul_of_nonneg_left this (Nat.cast_nonneg _) + linarith + +/-! ### 2. native floor -/ +noncomputable def Nfl (s : ℝ) : ℝ := 400 * (8 : ℝ) ^ s + 16 + 88 * (2 - (2 : ℝ) ^ s) +/-- the per-call native floor histogram: 88 stops priced T[2]-2P[1], 400 rank-8 mains, 16 owned (rank 1) + 176 stop credits -/ +def natFloor : Inv := ⟨[(2, 88)], [(8, 400), (1, 192)]⟩ +theorem natFloor_F (s : ℝ) : Finv s natFloor = -Nfl s := by + simp [Finv, natFloor, Fh, Nfl]; ring + +/-! ### 3. closed form of the caller family, all a,b >= 1 -/ +noncomputable def FB (a b th : ℕ) (s : ℝ) : ℝ := + 208 * (∑ i ∈ Finset.range a, ((8 * i + 9 : ℕ) : ℝ) ^ s + ∑ i ∈ Finset.range b, ((8 * i + 9 : ℕ) : ℝ) ^ s + + ((8 * (a + b) + 1 : ℕ) : ℝ) ^ s) + - 208 * (∑ i ∈ Finset.range (a - 2), ((8 * i + 16 : ℕ) : ℝ) ^ s + ∑ i ∈ Finset.range (b - 2), ((8 * i + 16 : ℕ) : ℝ) ^ s) + - (384 + 16 * ((a + b : ℕ) : ℝ)) * (8 : ℝ) ^ s - 96 * th - 32 * (9 : ℝ) ^ s + +theorem Fh_armT (s : ℝ) (n c : ℕ) : + Fh s (armT n c) = c * ∑ i ∈ Finset.range n, ((8 * i + 9 : ℕ) : ℝ) ^ s := by + induction n with + | zero => simp [armT, Fh] + | succ n ih => + have : armT (n + 1) c = armT n c ++ [(8 * n + 9, c)] := by simp [armT, List.range_succ] + rw [this, Fh_append, ih, Finset.sum_range_succ]; simp [Fh]; ring +theorem Fh_armP (s : ℝ) (m c : ℕ) : + Fh s (armP m c) = c * ∑ i ∈ Finset.range m, ((8 * i + 16 : ℕ) : ℝ) ^ s := by + induction m with + | zero => simp [armP, Fh] + | succ n ih => + have : armP (n + 1) c = armP n c ++ [(8 * n + 16, c)] := by simp [armP, List.range_succ] + rw [this, Fh_append, ih, Finset.sum_range_succ]; simp [Fh]; ring + +/-- bridge: CallerCost's histogram caller (a' + 2 | b' + 2), thin 4, has F = FB (a'+2) (b'+2) 4 -/ +theorem FB_eq (s : ℝ) (a' b' : ℕ) : Finv s (caller a' b') = FB (a' + 2) (b' + 2) 4 s := by + have hk : a' + 2 + (b' + 2) = a' + b' + 4 := by ring + simp only [Finv, caller, callerT, callerP, Fh_append, Fh_armT, Fh_armP, FB, hk] + simp [Fh] + ring + +theorem FB_th_mono (a b : ℕ) {th th0 : ℕ} (h : th0 ≤ th) (s : ℝ) : FB a b th s ≤ FB a b th0 s := by + unfold FB + have : (th0 : ℝ) ≤ th := by exact_mod_cast h + linarith + +/-! ### 3b. CORRECTION (R2/AUDIT2): arms of length 1. + cf.py / CALLERCO s1h priced every arm of 1 with 208 spurious one-stage lines (P[8]); the ledger-correct caller (r2.py port model) + has the same histograms except P[8] is lowered by 208 per arm of 1. FBc = FB + 208 * 8^s per arm of 1; for a,b >= 2 FBc = FB. -/ +def ind (x : ℕ) : ℕ := if x = 1 then 1 else 0 +noncomputable def FBc (a b th : ℕ) (s : ℝ) : ℝ := FB a b th s + 208 * ((ind a + ind b : ℕ) : ℝ) * (8 : ℝ) ^ s + +theorem FBc_two (a b th : ℕ) (s : ℝ) (ha : 2 ≤ a) (hb : 2 ≤ b) : FBc a b th s = FB a b th s := by + have h1 : ind a = 0 := by unfold ind; split_ifs <;> omega + have h2 : ind b = 0 := by unfold ind; split_ifs <;> omega + simp [FBc, h1, h2] + +theorem FBc_th_mono (a b : ℕ) {th th0 : ℕ} (h : th0 ≤ th) (s : ℝ) : FBc a b th s ≤ FBc a b th0 s := by + unfold FBc + have := FB_th_mono a b h s + linarith + +/-- the corrected caller histograms (a, b >= 1; thin queries th): arms as in CallerCost, P[8] = 384 + 16 (a+b) - 208 (#arms of 1) -/ +def callerG (a b th : ℕ) : Inv := + ⟨armT a 208 ++ armT b 208 ++ [(8 * (a + b) + 1, 208)], + armP (a - 2) 208 ++ armP (b - 2) 208 ++ [(8, 384 + 16 * (a + b) - 208 * (ind a + ind b)), (1, 96 * th), (9, 32)]⟩ + +theorem ind_le (a b : ℕ) (ha : 1 ≤ a) (hb : 1 ≤ b) : 208 * (ind a + ind b) ≤ 384 + 16 * (a + b) := by + unfold ind; split_ifs <;> omega + +theorem callerG_F (a b th : ℕ) (ha : 1 ≤ a) (hb : 1 ≤ b) (s : ℝ) : Finv s (callerG a b th) = FBc a b th s := by + have hle := ind_le a b ha hb + have hc : (((384 + 16 * (a + b) - 208 * (ind a + ind b) : ℕ)) : ℝ) = 384 + 16 * ((a + b : ℕ) : ℝ) - 208 * ((ind a + ind b : ℕ) : ℝ) := by + rw [Nat.cast_sub hle]; push_cast; ring + simp only [Finv, callerG, Fh_append, Fh_armT, Fh_armP, FBc, FB] + simp [Fh, hc] + push_cast + ring + +/-- for a, b >= 2 the corrected caller has the same F as CallerCost.caller (so reproduction of #7113 is unaffected) -/ +theorem callerG_eq_caller_F (a' b' : ℕ) (s : ℝ) : Finv s (callerG (a' + 2) (b' + 2) 4) = Finv s (caller a' b') := by + rw [callerG_F _ _ _ (by omega) (by omega), FBc_two _ _ _ _ (by omega) (by omega), FB_eq] + +/-- LEDGER LAW for ALL arms >= 1: S(callerG) = 3408 (a+b) - 208 (+ 96 (4 - th)); at a,b >= 2 this is CallerCost.S_caller. + (cf.py's version gave 3408 (a+b) - 208 - 1664 per arm of 1: the broken ledger.) -/ +theorem Sh_armP' (x : ℕ) (hx : 1 ≤ x) : + Sh (armP (x - 2) 208) = 208 * (4 * ((x : ℤ) - 2) * ((x : ℤ) - 2) + 12 * ((x : ℤ) - 2)) + 1664 * (ind x : ℤ) := by + rw [Sh_armP] + rcases Nat.lt_or_ge x 2 with h | h + · have : x = 1 := by omega + subst this; simp [ind] + · have h1 : ((x - 2 : ℕ) : ℤ) = (x : ℤ) - 2 := by omega + have h2 : ind x = 0 := by unfold ind; split_ifs <;> omega + rw [h1, h2]; simp + +theorem callerG_S (a b : ℕ) (ha : 1 ≤ a) (hb : 1 ≤ b) : + Sinv (callerG a b 4) = 3408 * ((a : ℤ) + b) - 208 := by + have hle := ind_le a b ha hb + have hc : (((384 + 16 * (a + b) - 208 * (ind a + ind b) : ℕ)) : ℤ) = 384 + 16 * ((a + b : ℕ) : ℤ) - 208 * ((ind a + ind b : ℕ) : ℤ) := by + rw [Nat.cast_sub hle]; push_cast; ring + simp only [Sinv, callerG, Sh_append, Sh_armT, Sh_armP' a ha, Sh_armP' b hb] + simp only [Sh, List.map_cons, List.sum_cons, List.map_nil, List.sum_nil] + rw [hc] + push_cast + ring + +/-! ### 4. class lemmas as explicit hypotheses -/ +/-- A caller in the audited class (CALLERFLOOR R1 sec 1): two-arm nested rho = 2 root with arms a|b >= 1 (k = a+b calls), + thin queries th. The CLASS LEMMAS are fields (hypotheses; a parallel lane proves them): + hB : B-form per-split optimality, pointwise in F(t) (CALLEROPEN Crossing + Floor lemmas; AUDIT1 item 1: only the D0/ratio form is proved); + hth : sign floor thin >= th0 (SIGNCAP/BEAUTY84; th0 = 4 built, 3 unbuilt); + hrho: rho >= 2 (rho = 1 needs t = -1, closed). rho = 2 enters only through the shape of FB (the two-arm closed form). -/ +structure InClass (th0 : ℕ) where + a : ℕ + b : ℕ + th : ℕ + rho : ℕ + ci : Inv + ha : 1 ≤ a + hb : 1 ≤ b + hth : th0 ≤ th + hrho : 2 ≤ rho + hB : ∀ s : ℝ, 0 ≤ s → s ≤ 1 → Finv s ci ≤ FBc a b th s + + +/-- the NUMERIC CERTIFICATE as a named hypothesis (REGENERATED, , from the AUDITED r2c.py; R1's cf.py-based list is withdrawn). + Statement: for every split a|b (a,b>=1) and 0 <= s <= 1-tbar, FBc a b th0 s - (a+b) Nfl s < 0. + Source: internal notes (lines 8-12: 1|1 root via cf.cert on the ledger-correct port model, th = th0; lines 13-17: 1|b, b = 2..59, + interval cover on [t0, 1] with pk._coef of joint(A(1,b), B(1,b), 1+b); lines 18-26: tail k >= 61 with R1's U plus the arm-of-1 correction + +208*8^s, U < 0 and U' < 0 by cover) together with a,b >= 2 splits from R1 tail.py lines 6-26 / cf.py `cert` lines 33-40 (unchanged: FBc = FB there, + FBc_two + callerG_eq_caller_F; r2.py asserts identity with the port model). Output r2c.out (th4: kbar .041944876391, cert True, 1|b True, tail True; + th3: .068120327915). Not discharged in Lean: ~1,800 (a,b) pairs of 40-digit interval covers, plus the R1 tail Jensen/MVT step (AUDIT2: unaudited). + tbar = .0419448764 (th0 = 4, rounded UP from .041944876391; A = 4 QUERY, B-form masks) and .0681203280 (th0 = 3: th3 B-form-A class only; + AUDIT2: scanned, not covered, for the true sign-floor class). -/ +def NumCert (th0 : ℕ) (tbar : ℝ) : Prop := + ∀ a b : ℕ, 1 ≤ a → 1 ≤ b → ∀ s : ℝ, 0 ≤ s → s ≤ 1 - tbar → FBc a b th0 s - ((a + b : ℕ) : ℝ) * Nfl s < 0 + +noncomputable def tbar4 : ℝ := 419448764 / 10 ^ 10 +noncomputable def tbar3 : ℝ := 681203280 / 10 ^ 10 + +/-- CEILING THEOREM (conditional on the class lemmas hB/hth/hrho, the native floor hN, and NumCert): + for every caller in the class and every native meeting the floor, the invoice F(t) = Finv (1-t) is < 0 for t >= tbar. -/ +theorem ceiling {th0 : ℕ} {tbar : ℝ} (hnum : NumCert th0 tbar) (c : InClass th0) (n : Inv) + (hN : ∀ s : ℝ, 0 ≤ s → s ≤ 1 → Finv s n ≤ -Nfl s) (htb : 0 ≤ tbar) + (s : ℝ) (hs0 : 0 ≤ s) (hs : s ≤ 1 - tbar) : + Finv s (invoice c.ci n (c.a + c.b)) < 0 := by + have hs1 : s ≤ 1 := by linarith + rw [invoice_F] + have h1 := c.hB s hs0 hs1 + have h2 := hN s hs0 hs1 + have h3 : ((c.a + c.b : ℕ) : ℝ) * Finv s n ≤ ((c.a + c.b : ℕ) : ℝ) * (-Nfl s) := + mul_le_mul_of_nonneg_left h2 (Nat.cast_nonneg _) + have h4 := FBc_th_mono c.a c.b c.hth s + have h5 := hnum c.a c.b c.ha c.hb s hs0 hs + linarith + +theorem ceiling4 (hnum : NumCert 4 tbar4) (c : InClass 4) (n : Inv) + (hN : ∀ s : ℝ, 0 ≤ s → s ≤ 1 → Finv s n ≤ -Nfl s) (t : ℝ) (ht : tbar4 ≤ t) (ht1 : t ≤ 1) : + Finv (1 - t) (invoice c.ci n (c.a + c.b)) < 0 := + ceiling hnum c n hN (by unfold tbar4; norm_num) (1 - t) (by linarith) (by linarith) + +theorem ceiling3 (hnum : NumCert 3 tbar3) (c : InClass 3) (n : Inv) + (hN : ∀ s : ℝ, 0 ≤ s → s ≤ 1 → Finv s n ≤ -Nfl s) (t : ℝ) (ht : tbar3 ≤ t) (ht1 : t ≤ 1) : + Finv (1 - t) (invoice c.ci n (c.a + c.b)) < 0 := + ceiling hnum c n hN (by unfold tbar3; norm_num) (1 - t) (by linarith) (by linarith) + + +/-! ### 5. kernel-checked numerics: rational rpow bounds through natural-number powers -/ +theorem rp_pow {x : ℕ} {p q : ℕ} (hq : 0 < q) : (((x : ℝ) ^ ((p : ℝ) / q)) ^ q) = (x : ℝ) ^ p := by + rw [← Real.rpow_natCast, ← Real.rpow_mul (Nat.cast_nonneg x), div_mul_cancel₀ _ (by exact_mod_cast hq.ne'), + Real.rpow_natCast] + +theorem rp_le_nat {x p q n d : ℕ} (hq : 0 < q) (hd : 0 < d) (h : x ^ p * d ^ q ≤ n ^ q) : + (x : ℝ) ^ ((p : ℝ) / q) ≤ (n : ℝ) / d := by + by_contra hc + have hc := not_le.mp hc + have hdr : (0 : ℝ) < d := by exact_mod_cast hd + have h1 : (((n : ℝ) / d)) ^ q < (((x : ℝ) ^ ((p : ℝ) / q)) ^ q) := + pow_lt_pow_left₀ hc (by positivity) hq.ne' + rw [rp_pow hq, div_pow, div_lt_iff₀ (by positivity)] at h1 + have h2 : ((x ^ p * d ^ q : ℕ) : ℝ) ≤ ((n ^ q : ℕ) : ℝ) := by exact_mod_cast h + push_cast at h2 + linarith + +theorem rp_ge_nat {x p q n d : ℕ} (hq : 0 < q) (hd : 0 < d) (h : n ^ q ≤ x ^ p * d ^ q) : + (n : ℝ) / d ≤ (x : ℝ) ^ ((p : ℝ) / q) := by + by_contra hc + have hc := not_le.mp hc + have hdr : (0 : ℝ) < d := by exact_mod_cast hd + have h1 : (((x : ℝ) ^ ((p : ℝ) / q))) ^ q < (((n : ℝ) / d)) ^ q := + pow_lt_pow_left₀ hc (by positivity) hq.ne' + rw [rp_pow hq, div_pow, lt_div_iff₀ (by positivity)] at h1 + have h2 : ((n ^ q : ℕ) : ℝ) ≤ ((x ^ p * d ^ q : ℕ) : ℝ) := by exact_mod_cast h + push_cast at h2 + linarith + +/-- upper bound of F-sum of a histogram at s = p/q by natural numerators U r / d -/ +theorem Fh_le (l : Hist) (p q d : ℕ) (U : ℕ → ℕ) (hq : 0 < q) (hd : 0 < d) + (h : ∀ pr ∈ l, pr.1 ^ p * d ^ q ≤ (U pr.1) ^ q) : + Fh ((p : ℝ) / q) l ≤ ((l.map fun pr => pr.2 * U pr.1).sum : ℕ) / (d : ℝ) := by + induction l with + | nil => simp [Fh] + | cons pr l ih => + have ih' := ih (fun r hr => h r (by simp [hr])) + have h1 := rp_le_nat hq hd (h pr (by simp)) + simp only [Fh, List.map_cons, List.sum_cons] at ih' ⊢ + rw [Nat.cast_add, Nat.cast_mul] + have h2 : (pr.2 : ℝ) * (pr.1 : ℝ) ^ ((p : ℝ) / q) ≤ (pr.2 : ℝ) * ((U pr.1 : ℝ) / d) := + mul_le_mul_of_nonneg_left h1 (Nat.cast_nonneg _) + have h3 : (pr.2 : ℝ) * ((U pr.1 : ℝ) / d) = ((pr.2 : ℝ) * U pr.1) / d := by ring + rw [add_div] + linarith + +theorem Fh_ge (l : Hist) (p q d : ℕ) (L : ℕ → ℕ) (hq : 0 < q) (hd : 0 < d) + (h : ∀ pr ∈ l, (L pr.1) ^ q ≤ pr.1 ^ p * d ^ q) : + ((l.map fun pr => pr.2 * L pr.1).sum : ℕ) / (d : ℝ) ≤ Fh ((p : ℝ) / q) l := by + induction l with + | nil => simp [Fh] + | cons pr l ih => + have ih' := ih (fun r hr => h r (by simp [hr])) + have h1 := rp_ge_nat hq hd (h pr (by simp)) + simp only [Fh, List.map_cons, List.sum_cons] at ih' ⊢ + rw [Nat.cast_add, Nat.cast_mul] + have h2 : (pr.2 : ℝ) * ((L pr.1 : ℝ) / d) ≤ (pr.2 : ℝ) * (pr.1 : ℝ) ^ ((p : ℝ) / q) := + mul_le_mul_of_nonneg_left h1 (Nat.cast_nonneg _) + have h3 : (pr.2 : ℝ) * ((L pr.1 : ℝ) / d) = ((pr.2 : ℝ) * L pr.1) / d := by ring + rw [add_div] + linarith + +/-- certificate cell: for s in [px/q, py/q], F(s) <= (T-part at py) - (P-part at px) < 0 by natural-number checks -/ +theorem cell_neg (i : Inv) (px py q d : ℕ) (U L : ℕ → ℕ) (hq : 0 < q) (hd : 0 < d) + (hrT : ∀ pr ∈ i.T, 1 ≤ pr.1) (hrP : ∀ pr ∈ i.P, 1 ≤ pr.1) + (hT : ∀ pr ∈ i.T, pr.1 ^ py * d ^ q ≤ (U pr.1) ^ q) + (hP : ∀ pr ∈ i.P, (L pr.1) ^ q ≤ pr.1 ^ px * d ^ q) + (hsum : (i.T.map fun pr => pr.2 * U pr.1).sum < (i.P.map fun pr => pr.2 * L pr.1).sum) + (s : ℝ) (hx : (px : ℝ) / q ≤ s) (hy : s ≤ (py : ℝ) / q) : Finv s i < 0 := by + have a1 := Fh_mono i.T hrT hy + have a2 := Fh_mono i.P hrP hx + have a3 := Fh_le i.T py q d U hq hd hT + have a4 := Fh_ge i.P px q d L hq hd hP + have hdr : (0 : ℝ) < d := by exact_mod_cast hd + have a5 : (((i.T.map fun pr => pr.2 * U pr.1).sum : ℕ) : ℝ) < (((i.P.map fun pr => pr.2 * L pr.1).sum : ℕ) : ℝ) := by + exact_mod_cast hsum + have a6 : (((i.T.map fun pr => pr.2 * U pr.1).sum : ℕ) : ℝ) / d < (((i.P.map fun pr => pr.2 * L pr.1).sum : ℕ) : ℝ) / d := + div_lt_div_of_pos_right a5 hdr + unfold Finv + linarith + +/-- the converse cell for a positive sign (used for the control bracket): F(s) > 0 at the single point s = p/q -/ +theorem pt_pos (i : Inv) (p q d : ℕ) (U L : ℕ → ℕ) (hq : 0 < q) (hd : 0 < d) + (hT : ∀ pr ∈ i.T, (L pr.1) ^ q ≤ pr.1 ^ p * d ^ q) + (hP : ∀ pr ∈ i.P, pr.1 ^ p * d ^ q ≤ (U pr.1) ^ q) + (hsum : (i.P.map fun pr => pr.2 * U pr.1).sum < (i.T.map fun pr => pr.2 * L pr.1).sum) : + 0 < Finv ((p : ℝ) / q) i := by + have a3 := Fh_le i.P p q d U hq hd hP + have a4 := Fh_ge i.T p q d L hq hd hT + have hdr : (0 : ℝ) < d := by exact_mod_cast hd + have a5 : (((i.P.map fun pr => pr.2 * U pr.1).sum : ℕ) : ℝ) < (((i.T.map fun pr => pr.2 * L pr.1).sum : ℕ) : ℝ) := by + exact_mod_cast hsum + have a6 : (((i.P.map fun pr => pr.2 * U pr.1).sum : ℕ) : ℝ) / d < (((i.T.map fun pr => pr.2 * L pr.1).sum : ℕ) : ℝ) / d := + div_lt_div_of_pos_right a5 hdr + unfold Finv + linarith + +/-! ### 6. the argmax split 2|2 (k = 4, thin 4): F < 0 for t >= 141/4096 (= .034424), 28-cell rational cover (python: internal notes cover, generators Nov15/jointceiling_gen/) + (the exact crossing .0336321541 needs rpow to 1e-10: held in NumCert, see sec 4) -/ +def I22 : Inv := invoice (caller 0 0) natFloor 4 +theorem I22_F (s : ℝ) : Finv s I22 = FBc 2 2 4 s - ((2 + 2 : ℕ) : ℝ) * Nfl s := by + rw [FBc_two 2 2 4 s (by norm_num) (by norm_num)] + have h := invoice_F s (caller 0 0) natFloor 4 + rw [natFloor_F, FB_eq] at h + show Finv s (invoice (caller 0 0) natFloor 4) = _ + rw [h]; push_cast; ring +theorem cell22_0 (s : ℝ) (hx : ((0 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ) ≤ s) (hy : s ≤ ((988 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) : + Finv s I22 < 0 := + cell_neg I22 0 988 4096 100000000 (fun r => if r = 2 then 118198437 else if r = 9 then 169892315 else if r = 17 then 198060441 else if r = 33 then 232424644 else 0) (fun r => if r = 1 then 99999999 else if r = 8 then 99999999 else if r = 9 then 99999999 else 0) (by norm_num) (by norm_num) + (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) s hx hy +theorem cell22_1 (s : ℝ) (hx : ((988 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ) ≤ s) (hy : s ≤ ((1977 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) : + Finv s I22 < 0 := + cell_neg I22 988 1977 4096 100000000 (fun r => if r = 2 then 139732347 else if r = 9 then 288788857 else if r = 17 then 392550812 else if r = 33 then 540673488 else 0) (fun r => if r = 1 then 99999999 else if r = 8 then 165133497 else if r = 9 then 169892312 else 0) (by norm_num) (by norm_num) + (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) s hx hy +theorem cell22_2 (s : ℝ) (hx : ((1977 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ) ≤ s) (hy : s ≤ ((2471 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) : + Finv s I22 < 0 := + cell_neg I22 1977 2471 4096 100000000 (fun r => if r = 2 then 151915755 else if r = 9 then 376415325 else if r = 17 then 552452252 else if r = 33 then 824282651 else 0) (fun r => if r = 1 then 99999999 else if r = 8 then 272829196 else if r = 9 then 288788854 else 0) (by norm_num) (by norm_num) + (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) s hx hy +theorem cell22_3 (s : ℝ) (hx : ((2471 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ) ≤ s) (hy : s ≤ ((2718 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) : + Finv s I22 < 0 := + cell_neg I22 2471 2718 4096 100000000 (fun r => if r = 2 then 158400208 else if r = 9 then 429744898 else if r = 17 then 655381507 else if r = 33 then 1017763102 else 0) (fun r => if r = 1 then 99999999 else if r = 8 then 350597193 else if r = 9 then 376415322 else 0) (by norm_num) (by norm_num) + (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) s hx hy +theorem cell22_4 (s : ℝ) (hx : ((2718 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ) ≤ s) (hy : s ≤ ((2966 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) : + Finv s I22 < 0 := + cell_neg I22 2718 2966 4096 100000000 (fun r => if r = 2 then 165189399 else if r = 9 then 490893330 else if r = 17 then 778025837 else if r = 33 then 1257731609 else 0) (fun r => if r = 1 then 99999999 else if r = 8 then 397436025 else if r = 9 then 429744895 else 0) (by norm_num) (by norm_num) + (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) s hx hy +theorem cell22_5 (s : ℝ) (hx : ((2966 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ) ≤ s) (hy : s ≤ ((3213 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) : + Finv s I22 < 0 := + cell_neg I22 2966 3213 4096 100000000 (fun r => if r = 2 then 172240432 else if r = 9 then 560441857 else if r = 17 then 922982473 else if r = 33 then 1552953737 else 0) (fun r => if r = 1 then 99999999 else if r = 8 then 450761181 else if r = 9 then 490893327 else 0) (by norm_num) (by norm_num) + (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) s hx hy +theorem cell22_6 (s : ℝ) (hx : ((3213 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ) ≤ s) (hy : s ≤ ((3336 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) : + Finv s I22 < 0 := + cell_neg I22 3213 3336 4096 100000000 (fun r => if r = 2 then 175863141 else if r = 9 then 598667655 else if r = 17 then 1004946564 else if r = 33 then 1724878163 else 0) (fun r => if r = 1 then 99999999 else if r = 8 then 510981649 else if r = 9 then 560441854 else 0) (by norm_num) (by norm_num) + (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) s hx hy +theorem cell22_7 (s : ℝ) (hx : ((3336 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ) ≤ s) (hy : s ≤ ((3460 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) : + Finv s I22 < 0 := + cell_neg I22 3336 3460 4096 100000000 (fun r => if r = 2 then 179592434 else if r = 9 then 639843844 else if r = 17 then 1094946471 else if r = 33 then 1917472133 else 0) (fun r => if r = 1 then 99999999 else if r = 8 then 543906765 else if r = 9 then 598667652 else 0) (by norm_num) (by norm_num) + (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) s hx hy +theorem cell22_8 (s : ℝ) (hx : ((3460 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ) ≤ s) (hy : s ≤ ((3583 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) : + Finv s I22 < 0 := + cell_neg I22 3460 3583 4096 100000000 (fun r => if r = 2 then 183369777 else if r = 9 then 683485377 else if r = 17 then 1192181571 else if r = 33 then 2129751667 else 0) (fun r => if r = 1 then 99999999 else if r = 8 then 579247408 else if r = 9 then 639843841 else 0) (by norm_num) (by norm_num) + (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) s hx hy +theorem cell22_9 (s : ℝ) (hx : ((3583 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ) ≤ s) (hy : s ≤ ((3645 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) : + Finv s I22 < 0 := + cell_neg I22 3583 3645 4096 100000000 (fun r => if r = 2 then 185303816 else if r = 9 then 706599503 else if r = 17 then 1244421092 else if r = 33 then 2245506338 else 0) (fun r => if r = 1 then 99999999 else if r = 8 then 616571231 else if r = 9 then 683485374 else 0) (by norm_num) (by norm_num) + (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) s hx hy +theorem cell22_10 (s : ℝ) (hx : ((3645 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ) ≤ s) (hy : s ≤ ((3707 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) : + Finv s I22 < 0 := + cell_neg I22 3645 3707 4096 100000000 (fun r => if r = 2 then 187258254 else if r = 9 then 730495304 else if r = 17 then 1298949666 else if r = 33 then 2367552420 else 0) (fun r => if r = 1 then 99999999 else if r = 8 then 636287037 else if r = 9 then 706599500 else 0) (by norm_num) (by norm_num) + (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) s hx hy +theorem cell22_11 (s : ℝ) (hx : ((3707 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ) ≤ s) (hy : s ≤ ((3769 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) : + Finv s I22 < 0 := + cell_neg I22 3707 3769 4096 100000000 (fun r => if r = 2 then 189233305 else if r = 9 then 755199213 else if r = 17 then 1355867597 else if r = 33 then 2496231861 else 0) (fun r => if r = 1 then 99999999 else if r = 8 then 656633287 else if r = 9 then 730495301 else 0) (by norm_num) (by norm_num) + (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) s hx hy +theorem cell22_12 (s : ℝ) (hx : ((3769 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ) ≤ s) (hy : s ≤ ((3800 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) : + Finv s I22 < 0 := + cell_neg I22 3769 3800 4096 100000000 (fun r => if r = 2 then 190228629 else if r = 9 then 767862713 else if r = 17 then 1385255112 else if r = 33 then 2563171002 else 0) (fun r => if r = 1 then 99999999 else if r = 8 then 677630139 else if r = 9 then 755199210 else 0) (by norm_num) (by norm_num) + (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) s hx hy +theorem cell22_13 (s : ℝ) (hx : ((3800 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ) ≤ s) (hy : s ≤ ((3831 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) : + Finv s I22 < 0 := + cell_neg I22 3800 3831 4096 100000000 (fun r => if r = 2 then 191229188 else if r = 9 then 780738560 else if r = 17 then 1415279582 else if r = 33 then 2631905189 else 0) (fun r => if r = 1 then 99999999 else if r = 8 then 688379017 else if r = 9 then 767862710 else 0) (by norm_num) (by norm_num) + (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) s hx hy +theorem cell22_14 (s : ℝ) (hx : ((3831 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ) ≤ s) (hy : s ≤ ((3862 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) : + Finv s I22 < 0 := + cell_neg I22 3831 3862 4096 100000000 (fun r => if r = 2 then 192235010 else if r = 9 then 793830314 else if r = 17 then 1445954812 else if r = 33 then 2702482558 else 0) (fun r => if r = 1 then 99999999 else if r = 8 then 699298398 else if r = 9 then 780738557 else 0) (by norm_num) (by norm_num) + (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) s hx hy +theorem cell22_15 (s : ℝ) (hx : ((3862 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ) ≤ s) (hy : s ≤ ((3877 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) : + Finv s I22 < 0 := + cell_neg I22 3862 3877 4096 100000000 (fun r => if r = 2 then 192723596 else if r = 9 then 800243619 else if r = 17 then 1461035469 else if r = 33 then 2737309242 else 0) (fun r => if r = 1 then 99999999 else if r = 8 then 710390987 else if r = 9 then 793830311 else 0) (by norm_num) (by norm_num) + (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) s hx hy +theorem cell22_16 (s : ℝ) (hx : ((3877 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ) ≤ s) (hy : s ≤ ((3893 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) : + Finv s I22 < 0 := + cell_neg I22 3877 3893 4096 100000000 (fun r => if r = 2 then 193246122 else if r = 9 then 807141597 else if r = 17 then 1477294906 else if r = 33 then 2774952534 else 0) (fun r => if r = 1 then 99999999 else if r = 8 then 715821366 else if r = 9 then 800243616 else 0) (by norm_num) (by norm_num) + (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) s hx hy +theorem cell22_17 (s : ℝ) (hx : ((3893 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ) ≤ s) (hy : s ≤ ((3908 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) : + Finv s I22 < 0 := + cell_neg I22 3893 3908 4096 100000000 (fun r => if r = 2 then 193737278 else if r = 9 then 813662443 else if r = 17 then 1492702427 else if r = 33 then 2810713133 else 0) (fun r => if r = 1 then 99999999 else if r = 8 then 721659532 else if r = 9 then 807141594 else 0) (by norm_num) (by norm_num) + (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) s hx hy +theorem cell22_18 (s : ℝ) (hx : ((3908 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ) ≤ s) (hy : s ≤ ((3924 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) : + Finv s I22 < 0 := + cell_neg I22 3908 3924 4096 100000000 (fun r => if r = 2 then 194262553 else if r = 9 then 820676089 else if r = 17 then 1509314276 else if r = 33 then 2849365870 else 0) (fun r => if r = 1 then 99999999 else if r = 8 then 727176050 else if r = 9 then 813662440 else 0) (by norm_num) (by norm_num) + (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) s hx hy +theorem cell22_19 (s : ℝ) (hx : ((3924 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ) ≤ s) (hy : s ≤ ((3931 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) : + Finv s I22 < 0 := + cell_neg I22 3924 3931 4096 100000000 (fun r => if r = 2 then 194492808 else if r = 9 then 823763539 else if r = 17 then 1516639972 else if r = 33 then 2866443162 else 0) (fun r => if r = 1 then 99999999 else if r = 8 then 733106824 else if r = 9 then 820676086 else 0) (by norm_num) (by norm_num) + (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) s hx hy +theorem cell22_20 (s : ℝ) (hx : ((3931 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ) ≤ s) (hy : s ≤ ((3939 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) : + Finv s I22 < 0 := + cell_neg I22 3931 3939 4096 100000000 (fun r => if r = 2 then 194756291 else if r = 9 then 827306279 else if r = 17 then 1525055745 else if r = 33 then 2886085429 else 0) (fun r => if r = 1 then 99999999 else if r = 8 then 735716725 else if r = 9 then 823763536 else 0) (by norm_num) (by norm_num) + (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) s hx hy +theorem cell22_21 (s : ℝ) (hx : ((3939 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ) ≤ s) (hy : s ≤ ((3943 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) : + Finv s I22 < 0 := + cell_neg I22 3939 3943 4096 100000000 (fun r => if r = 2 then 194888167 else if r = 9 then 829083358 else if r = 17 then 1529281127 else if r = 33 then 2895956979 else 0) (fun r => if r = 1 then 99999999 else if r = 8 then 738710847 else if r = 9 then 827306276 else 0) (by norm_num) (by norm_num) + (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) s hx hy +theorem cell22_22 (s : ℝ) (hx : ((3943 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ) ≤ s) (hy : s ≤ ((3947 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) : + Finv s I22 < 0 := + cell_neg I22 3943 3947 4096 100000000 (fun r => if r = 2 then 195020132 else if r = 9 then 830864255 else if r = 17 then 1533518216 else if r = 33 then 2905862294 else 0) (fun r => if r = 1 then 99999999 else if r = 8 then 740212475 else if r = 9 then 829083355 else 0) (by norm_num) (by norm_num) + (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) s hx hy +theorem cell22_23 (s : ℝ) (hx : ((3947 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ) ≤ s) (hy : s ≤ ((3949 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) : + Finv s I22 < 0 := + cell_neg I22 3947 3949 4096 100000000 (fun r => if r = 2 then 195086147 else if r = 9 then 831756137 else if r = 17 then 1535641161 else if r = 33 then 2910827650 else 0) (fun r => if r = 1 then 99999999 else if r = 8 then 741717155 else if r = 9 then 830864252 else 0) (by norm_num) (by norm_num) + (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) s hx hy +theorem cell22_24 (s : ℝ) (hx : ((3949 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ) ≤ s) (hy : s ≤ ((3951 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) : + Finv s I22 < 0 := + cell_neg I22 3949 3951 4096 100000000 (fun r => if r = 2 then 195152186 else if r = 9 then 832648977 else if r = 17 then 1537767044 else if r = 33 then 2915801489 else 0) (fun r => if r = 1 then 99999999 else if r = 8 then 742470642 else if r = 9 then 831756134 else 0) (by norm_num) (by norm_num) + (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) s hx hy +theorem cell22_25 (s : ℝ) (hx : ((3951 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ) ≤ s) (hy : s ≤ ((3953 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) : + Finv s I22 < 0 := + cell_neg I22 3951 3953 4096 100000000 (fun r => if r = 2 then 195218246 else if r = 9 then 833542775 else if r = 17 then 1539895871 else if r = 33 then 2920783828 else 0) (fun r => if r = 1 then 99999999 else if r = 8 then 743224894 else if r = 9 then 832648974 else 0) (by norm_num) (by norm_num) + (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) s hx hy +theorem cell22_26 (s : ℝ) (hx : ((3953 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ) ≤ s) (hy : s ≤ ((3954 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) : + Finv s I22 < 0 := + cell_neg I22 3953 3954 4096 100000000 (fun r => if r = 2 then 195251285 else if r = 9 then 833990034 else if r = 17 then 1540961389 else if r = 33 then 2923278189 else 0) (fun r => if r = 1 then 99999999 else if r = 8 then 743979912 else if r = 9 then 833542772 else 0) (by norm_num) (by norm_num) + (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) s hx hy +theorem cell22_27 (s : ℝ) (hx : ((3954 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ) ≤ s) (hy : s ≤ ((3955 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) : + Finv s I22 < 0 := + cell_neg I22 3954 3955 4096 100000000 (fun r => if r = 2 then 195284329 else if r = 9 then 834437532 else if r = 17 then 1542027645 else if r = 33 then 2925774680 else 0) (fun r => if r = 1 then 99999999 else if r = 8 then 744357709 else if r = 9 then 833990031 else 0) (by norm_num) (by norm_num) + (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) s hx hy +theorem I22_neg (s : ℝ) (h0 : 0 ≤ s) (h1 : s ≤ ((3955 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) : Finv s I22 < 0 := by + rcases le_total s (((988 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) with h2 | h2 + · exact cell22_0 s (by rw [Nat.cast_zero, zero_div]; exact h0) h2 + · rcases le_total s (((1977 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) with h3 | h3 + · exact cell22_1 s h2 h3 + · rcases le_total s (((2471 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) with h4 | h4 + · exact cell22_2 s h3 h4 + · rcases le_total s (((2718 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) with h5 | h5 + · exact cell22_3 s h4 h5 + · rcases le_total s (((2966 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) with h6 | h6 + · exact cell22_4 s h5 h6 + · rcases le_total s (((3213 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) with h7 | h7 + · exact cell22_5 s h6 h7 + · rcases le_total s (((3336 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) with h8 | h8 + · exact cell22_6 s h7 h8 + · rcases le_total s (((3460 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) with h9 | h9 + · exact cell22_7 s h8 h9 + · rcases le_total s (((3583 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) with h10 | h10 + · exact cell22_8 s h9 h10 + · rcases le_total s (((3645 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) with h11 | h11 + · exact cell22_9 s h10 h11 + · rcases le_total s (((3707 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) with h12 | h12 + · exact cell22_10 s h11 h12 + · rcases le_total s (((3769 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) with h13 | h13 + · exact cell22_11 s h12 h13 + · rcases le_total s (((3800 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) with h14 | h14 + · exact cell22_12 s h13 h14 + · rcases le_total s (((3831 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) with h15 | h15 + · exact cell22_13 s h14 h15 + · rcases le_total s (((3862 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) with h16 | h16 + · exact cell22_14 s h15 h16 + · rcases le_total s (((3877 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) with h17 | h17 + · exact cell22_15 s h16 h17 + · rcases le_total s (((3893 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) with h18 | h18 + · exact cell22_16 s h17 h18 + · rcases le_total s (((3908 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) with h19 | h19 + · exact cell22_17 s h18 h19 + · rcases le_total s (((3924 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) with h20 | h20 + · exact cell22_18 s h19 h20 + · rcases le_total s (((3931 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) with h21 | h21 + · exact cell22_19 s h20 h21 + · rcases le_total s (((3939 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) with h22 | h22 + · exact cell22_20 s h21 h22 + · rcases le_total s (((3943 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) with h23 | h23 + · exact cell22_21 s h22 h23 + · rcases le_total s (((3947 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) with h24 | h24 + · exact cell22_22 s h23 h24 + · rcases le_total s (((3949 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) with h25 | h25 + · exact cell22_23 s h24 h25 + · rcases le_total s (((3951 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) with h26 | h26 + · exact cell22_24 s h25 h26 + · rcases le_total s (((3953 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) with h27 | h27 + · exact cell22_25 s h26 h27 + · rcases le_total s (((3954 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) with h28 | h28 + · exact cell22_26 s h27 h28 + · exact cell22_27 s h28 h1 + +/-- t >= 141/4096 (s <= 3955/4096): the invoice F of EVERY native at the floor with the argmax caller 2|2 is negative -/ +theorem split22_ceiling (t : ℝ) (ht : (141 : ℝ) / 4096 ≤ t) (ht1 : t ≤ 1) : Finv (1 - t) I22 < 0 := by + apply I22_neg (1 - t) (by linarith) + have : ((3955 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ) = 1 - 141 / 4096 := by norm_num + rw [this]; linarith + +/-! ### 7. the control C(8|9) (= #7113 caller, CallerCost.reproduction) at the native floor, k = 17: the root of F(t) lies in (.0204, .0205) + (R3 control .0204110964; exact root needs rpow to 1e-10, not done in kernel) -/ +def I89 : Inv := invoice (caller 6 7) natFloor 17 +theorem I89_F (s : ℝ) : Finv s I89 = FB 8 9 4 s - ((8 + 9 : ℕ) : ℝ) * Nfl s := by + have h := invoice_F s (caller 6 7) natFloor 17 + rw [natFloor_F, FB_eq] at h + show Finv s (invoice (caller 6 7) natFloor 17) = _ + rw [h]; push_cast; ring +/-- F(t = .0204) > 0 (s = 2449/2500) -/ +theorem control_pos : 0 < Finv (((2449 : ℕ) : ℝ) / ((2500 : ℕ) : ℝ)) I89 := + pt_pos I89 2449 2500 100000000 (fun r => if r = 1 then 100000001 else if r = 8 then 766773248 else if r = 9 then 860549711 else if r = 16 then 1512014428 else if r = 24 then 2249339100 else if r = 32 then 2981569375 else if r = 40 then 3710034667 else if r = 48 then 4435513611 else if r = 56 then 5158518488 else if r = 64 then 5879412111 else 0) (fun r => if r = 2 then 197191859 else if r = 9 then 860549708 else if r = 17 then 1604529710 else if r = 25 then 2341111144 else if r = 33 then 3072813876 else if r = 41 then 3800870438 else if r = 49 then 4526015947 else if r = 57 then 5248739375 else if r = 65 then 5969389592 else if r = 73 then 6688228062 else if r = 137 then 12391716458 else 0) (by norm_num) (by norm_num) + (by decide +kernel) (by decide +kernel) (by decide +kernel) +/-- F(t = .0205) < 0 (s = 1959/2000) -/ +theorem control_neg : Finv (((1959 : ℕ) : ℝ) / ((2000 : ℕ) : ℝ)) I89 < 0 := + cell_neg I89 1959 1959 2000 100000000 (fun r => if r = 2 then 197178194 else if r = 9 then 860360650 else if r = 17 then 1604075180 else if r = 25 then 2340357693 else if r = 33 then 3071739655 else if r = 41 then 3799459223 else if r = 49 then 4524254849 else if r = 57 then 5246617715 else if r = 65 then 5966898261 else if r = 73 then 6685359123 else if r = 137 then 12385621260 else 0) (fun r => if r = 1 then 99999999 else if r = 8 then 766613815 else if r = 9 then 860360647 else if r = 16 then 1511595264 else if r = 24 then 2248624359 else if r = 32 then 2980536218 else if r = 40 then 3708666329 else if r = 48 then 4433796864 else if r = 56 then 5156442418 else if r = 64 then 5876967437 else 0) (by norm_num) (by norm_num) + (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) _ le_rfl le_rfl +/-- the control brackets the R3 value .0204110964: F(.0204) > 0 > F(.0205) for the exact #7113 caller invoice at the floor native -/ +theorem control_bracket : + 0 < Finv (1 - (204 : ℝ) / 10000) I89 ∧ Finv (1 - (205 : ℝ) / 10000) I89 < 0 := by + constructor + · have h := control_pos + have e : ((2449 : ℕ) : ℝ) / ((2500 : ℕ) : ℝ) = 1 - 204 / 10000 := by norm_num + rwa [e] at h + · have h := control_neg + have e : ((1959 : ℕ) : ℝ) / ((2000 : ℕ) : ℝ) = 1 - 205 / 10000 := by norm_num + rwa [e] at h + + +/-! ### 8. the CORRECTED argmax split 1|1 (k = 2, thin 4, arms of 1 priced by the ledger): F < 0 for t >= 176/4096 = 0.042969 (root .0419448764), 36 rational cells. + (internal notes; the exact root needs rpow to 1e-10, held in NumCert) -/ +def I11 : Inv := invoice (callerG 1 1 4) natFloor 2 +theorem I11_F (s : ℝ) : Finv s I11 = FBc 1 1 4 s - ((1 + 1 : ℕ) : ℝ) * Nfl s := by + have h := invoice_F s (callerG 1 1 4) natFloor 2 + rw [natFloor_F, callerG_F 1 1 4 le_rfl le_rfl] at h + show Finv s (invoice (callerG 1 1 4) natFloor 2) = _ + rw [h]; push_cast; ring +theorem cell11_0 (s : ℝ) (hx : ((0 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ) ≤ s) (hy : s ≤ ((980 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) : + Finv s I11 < 0 := + cell_neg I11 0 980 4096 100000000000 (fun r => if r = 2 then 118038526172 else if r = 9 then 169164790567 else if r = 17 then 196967474893 else 0) (fun r => if r = 1 then 99999999999 else if r = 8 then 99999999999 else if r = 9 then 99999999999 else 0) (by norm_num) (by norm_num) + (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) s hx hy +theorem cell11_1 (s : ℝ) (hx : ((980 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ) ≤ s) (hy : s ≤ ((1470 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) : + Finv s I11 < 0 := + cell_neg I11 980 1470 4096 100000000000 (fun r => if r = 2 then 128243590121 else if r = 9 then 220021419926 else if r = 17 then 276434202378 else 0) (fun r => if r = 1 then 99999999999 else if r = 8 then 164464184067 else if r = 9 then 169164790564 else 0) (by norm_num) (by norm_num) + (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) s hx hy +theorem cell11_2 (s : ℝ) (hx : ((1470 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ) ≤ s) (hy : s ≤ ((1960 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) : + Finv s I11 < 0 := + cell_neg I11 1470 1960 4096 100000000000 (fun r => if r = 2 then 139330936607 else if r = 9 then 286167263672 else if r = 17 then 387961861652 else 0) (fun r => if r = 1 then 99999999999 else if r = 8 then 210914774109 else if r = 9 then 220021419923 else 0) (by norm_num) (by norm_num) + (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) s hx hy +theorem cell11_3 (s : ℝ) (hx : ((1960 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ) ≤ s) (hy : s ≤ ((2450 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) : + Finv s I11 < 0 := + cell_neg I11 1960 2450 4096 100000000000 (fun r => if r = 2 then 151376843687 else if r = 9 then 372198774216 else if r = 17 then 544485468158 else 0) (fun r => if r = 1 then 99999999999 else if r = 8 then 270484678412 else if r = 9 then 286167263669 else 0) (by norm_num) (by norm_num) + (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) s hx hy +theorem cell11_4 (s : ℝ) (hx : ((2450 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ) ≤ s) (hy : s ≤ ((2695 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) : + Finv s I11 < 0 := + cell_neg I11 2450 2695 4096 100000000000 (fun r => if r = 2 then 157784882305 else if r = 9 then 424475308227 else if r = 17 then 645037439188 else 0) (fun r => if r = 1 then 99999999999 else if r = 8 then 346879262320 else if r = 9 then 372198774213 else 0) (by norm_num) (by norm_num) + (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) s hx hy +theorem cell11_5 (s : ℝ) (hx : ((2695 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ) ≤ s) (hy : s ≤ ((2940 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) : + Finv s I11 < 0 := + cell_neg I11 2695 2940 4096 100000000000 (fun r => if r = 2 then 164464184070 else if r = 9 then 484094252257 else if r = 17 then 764158682436 else 0) (fun r => if r = 1 then 99999999999 else if r = 8 then 392822333018 else if r = 9 then 424475308224 else 0) (by norm_num) (by norm_num) + (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) s hx hy +theorem cell11_6 (s : ℝ) (hx : ((2940 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ) ≤ s) (hy : s ≤ ((3185 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) : + Finv s I11 < 0 := + cell_neg I11 2940 3185 4096 100000000000 (fun r => if r = 2 then 171426232010 else if r = 9 then 552086871782 else if r = 17 then 905278448145 else 0) (fun r => if r = 1 then 99999999999 else if r = 8 then 444850419381 else if r = 9 then 484094252254 else 0) (by norm_num) (by norm_num) + (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) s hx hy +theorem cell11_7 (s : ℝ) (hx : ((3185 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ) ≤ s) (hy : s ≤ ((3307 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) : + Finv s I11 < 0 := + cell_neg I11 3185 3307 4096 100000000000 (fun r => if r = 2 then 175002198569 else if r = 9 then 589426533829 else if r = 17 then 984988805396 else 0) (fun r => if r = 1 then 99999999999 else if r = 8 then 503769462655 else if r = 9 then 552086871779 else 0) (by norm_num) (by norm_num) + (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) s hx hy +theorem cell11_8 (s : ℝ) (hx : ((3307 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ) ≤ s) (hy : s ≤ ((3430 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) : + Finv s I11 < 0 := + cell_neg I11 3307 3430 4096 100000000000 (fun r => if r = 2 then 178682995252 else if r = 9 then 629629276888 else if r = 17 then 1072459277781 else 0) (fun r => if r = 1 then 99999999999 else if r = 8 then 535957699595 else if r = 9 then 589426533826 else 0) (by norm_num) (by norm_num) + (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) s hx hy +theorem cell11_9 (s : ℝ) (hx : ((3430 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ) ≤ s) (hy : s ≤ ((3491 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) : + Finv s I11 < 0 := + cell_neg I11 3430 3491 4096 100000000000 (fun r => if r = 2 then 180537047876 else if r = 9 then 650573014604 else if r = 17 then 1118678695528 else 0) (fun r => if r = 1 then 99999999999 else if r = 8 then 570492148478 else if r = 9 then 629629276885 else 0) (by norm_num) (by norm_num) + (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) s hx hy +theorem cell11_10 (s : ℝ) (hx : ((3491 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ) ≤ s) (hy : s ≤ ((3552 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) : + Finv s I11 < 0 := + cell_neg I11 3491 3552 4096 100000000000 (fun r => if r = 2 then 182410338542 else if r = 9 then 672213416478 else if r = 17 then 1166890016018 else 0) (fun r => if r = 1 then 99999999999 else if r = 8 then 588435695526 else if r = 9 then 650573014601 else 0) (by norm_num) (by norm_num) + (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) s hx hy +theorem cell11_11 (s : ℝ) (hx : ((3552 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ) ≤ s) (hy : s ≤ ((3613 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) : + Finv s I11 < 0 := + cell_neg I11 3552 3613 4096 100000000000 (fun r => if r = 2 then 184303066870 else if r = 9 then 694573656069 else if r = 17 then 1217179083616 else 0) (fun r => if r = 1 then 99999999999 else if r = 8 then 606943616478 else if r = 9 then 672213416475 else 0) (by norm_num) (by norm_num) + (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) s hx hy +theorem cell11_12 (s : ℝ) (hx : ((3613 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ) ≤ s) (hy : s ≤ ((3675 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) : + Finv s I11 < 0 := + cell_neg I11 3613 3675 4096 100000000000 (fun r => if r = 2 then 186246949593 else if r = 9 then 718062766164 else if r = 17 then 1270513956070 else 0) (fun r => if r = 1 then 99999999999 else if r = 8 then 626033662444 else if r = 9 then 694573656066 else 0) (by norm_num) (by norm_num) + (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) s hx hy +theorem cell11_13 (s : ℝ) (hx : ((3675 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ) ≤ s) (hy : s ≤ ((3705 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) : + Finv s I11 < 0 := + cell_neg I11 3675 3705 4096 100000000000 (fun r => if r = 2 then 187194885136 else if r = 9 then 729712000715 else if r = 17 then 1297153933706 else 0) (fun r => if r = 1 then 99999999999 else if r = 8 then 646052044837 else if r = 9 then 718062766161 else 0) (by norm_num) (by norm_num) + (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) s hx hy +theorem cell11_14 (s : ℝ) (hx : ((3705 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ) ≤ s) (hy : s ≤ ((3736 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) : + Finv s I11 < 0 := + cell_neg I11 3705 3736 4096 100000000000 (fun r => if r = 2 then 188179487410 else if r = 9 then 741948120277 else if r = 17 then 1325268869852 else 0) (fun r => if r = 1 then 99999999999 else if r = 8 then 655966912907 else if r = 9 then 729712000712 else 0) (by norm_num) (by norm_num) + (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) s hx hy +theorem cell11_15 (s : ℝ) (hx : ((3736 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ) ≤ s) (hy : s ≤ ((3766 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) : + Finv s I11 < 0 := + cell_neg I11 3736 3766 4096 100000000000 (fun r => if r = 2 then 189137258933 else if r = 9 then 753984850330 else if r = 17 then 1353056941668 else 0) (fun r => if r = 1 then 99999999999 else if r = 8 then 666372158432 else if r = 9 then 741948120274 else 0) (by norm_num) (by norm_num) + (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) s hx hy +theorem cell11_16 (s : ℝ) (hx : ((3766 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ) ≤ s) (hy : s ≤ ((3797 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) : + Finv s I11 < 0 := + cell_neg I11 3766 3797 4096 100000000000 (fun r => if r = 2 then 190132077649 else if r = 9 then 766627987305 else if r = 17 then 1382383537787 else 0) (fun r => if r = 1 then 99999999999 else if r = 8 then 676598876371 else if r = 9 then 753984850327 else 0) (by norm_num) (by norm_num) + (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) s hx hy +theorem cell11_17 (s : ℝ) (hx : ((3797 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ) ≤ s) (hy : s ≤ ((3812 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) : + Finv s I11 < 0 := + cell_neg I11 3797 3812 4096 100000000000 (fun r => if r = 2 then 190615318327 else if r = 9 then 772821526227 else if r = 17 then 1396801175565 else 0) (fun r => if r = 1 then 99999999999 else if r = 8 then 687331395485 else if r = 9 then 766627987302 else 0) (by norm_num) (by norm_num) + (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) s hx hy +theorem cell11_18 (s : ℝ) (hx : ((3812 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ) ≤ s) (hy : s ≤ ((3827 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) : + Finv s I11 < 0 := + cell_neg I11 3812 3827 4096 100000000000 (fun r => if r = 2 then 191099787212 else if r = 9 then 779065102357 else if r = 17 then 1411369182812 else 0) (fun r => if r = 1 then 99999999999 else if r = 8 then 692585501907 else if r = 9 then 772821526224 else 0) (by norm_num) (by norm_num) + (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) s hx hy +theorem cell11_19 (s : ℝ) (hx : ((3827 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ) ≤ s) (hy : s ≤ ((3842 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) : + Finv s I11 < 0 := + cell_neg I11 3827 3842 4096 100000000000 (fun r => if r = 2 then 191585487426 else if r = 9 then 785359119943 else if r = 17 then 1426089127815 else 0) (fun r => if r = 1 then 99999999999 else if r = 8 then 697879771828 else if r = 9 then 779065102354 else 0) (by norm_num) (by norm_num) + (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) s hx hy +theorem cell11_20 (s : ℝ) (hx : ((3842 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ) ≤ s) (hy : s ≤ ((3858 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) : + Finv s I11 < 0 := + cell_neg I11 3842 3858 4096 100000000000 (fun r => if r = 2 then 192104928378 else if r = 9 then 792128795609 else if r = 17 then 1441959657406 else 0) (fun r => if r = 1 then 99999999999 else if r = 8 then 703214512268 else if r = 9 then 785359119940 else 0) (by norm_num) (by norm_num) + (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) s hx hy +theorem cell11_21 (s : ℝ) (hx : ((3858 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ) ≤ s) (hy : s ≤ ((3873 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) : + Finv s I11 < 0 := + cell_neg I11 3858 3873 4096 100000000000 (fun r => if r = 2 then 192593183263 else if r = 9 then 798528353945 else if r = 17 then 1456998647283 else 0) (fun r => if r = 1 then 99999999999 else if r = 8 then 708949858185 else if r = 9 then 792128795606 else 0) (by norm_num) (by norm_num) + (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) s hx hy +theorem cell11_22 (s : ℝ) (hx : ((3873 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ) ≤ s) (hy : s ≤ ((3881 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) : + Finv s I11 < 0 := + cell_neg I11 3873 3881 4096 100000000000 (fun r => if r = 2 then 192854093080 else if r = 9 then 801962565455 else if r = 17 then 1465083472409 else 0) (fun r => if r = 1 then 99999999999 else if r = 8 then 714369220704 else if r = 9 then 798528353942 else 0) (by norm_num) (by norm_num) + (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) s hx hy +theorem cell11_23 (s : ℝ) (hx : ((3881 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ) ≤ s) (hy : s ≤ ((3889 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) : + Finv s I11 < 0 := + cell_neg I11 3881 3889 4096 100000000000 (fun r => if r = 2 then 193115356356 else if r = 9 then 805411546396 else if r = 17 then 1473213159894 else 0) (fun r => if r = 1 then 99999999999 else if r = 8 then 717276466233 else if r = 9 then 801962565452 else 0) (by norm_num) (by norm_num) + (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) s hx hy +theorem cell11_24 (s : ℝ) (hx : ((3889 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ) ≤ s) (hy : s ≤ ((3896 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) : + Finv s I11 < 0 := + cell_neg I11 3889 3896 4096 100000000000 (fun r => if r = 2 then 193344252046 else if r = 9 then 808441570194 else if r = 17 then 1480363633263 else 0) (fun r => if r = 1 then 99999999999 else if r = 8 then 720195543287 else if r = 9 then 805411546393 else 0) (by norm_num) (by norm_num) + (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) s hx hy +theorem cell11_25 (s : ℝ) (hx : ((3896 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ) ≤ s) (hy : s ≤ ((3900 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) : + Finv s I11 < 0 := + cell_neg I11 3896 3900 4096 100000000000 (fun r => if r = 2 then 193475171374 else if r = 9 then 810178127625 else if r = 17 then 1484465189525 else 0) (fun r => if r = 1 then 99999999999 else if r = 8 then 722759479103 else if r = 9 then 808441570191 else 0) (by norm_num) (by norm_num) + (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) s hx hy +theorem cell11_26 (s : ℝ) (hx : ((3900 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ) ≤ s) (hy : s ≤ ((3904 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) : + Finv s I11 < 0 := + cell_neg I11 3900 3904 4096 100000000000 (fun r => if r = 2 then 193606179351 else if r = 9 then 811918415234 else if r = 17 then 1488578109728 else 0) (fun r => if r = 1 then 99999999999 else if r = 8 then 724228681377 else if r = 9 then 810178127622 else 0) (by norm_num) (by norm_num) + (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) s hx hy +theorem cell11_27 (s : ℝ) (hx : ((3904 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ) ≤ s) (hy : s ≤ ((3908 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) : + Finv s I11 < 0 := + cell_neg I11 3904 3908 4096 100000000000 (fun r => if r = 2 then 193737276037 else if r = 9 then 813662441034 else if r = 17 then 1492702425356 else 0) (fun r => if r = 1 then 99999999999 else if r = 8 then 725700870199 else if r = 9 then 811918415231 else 0) (by norm_num) (by norm_num) + (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) s hx hy +theorem cell11_28 (s : ℝ) (hx : ((3908 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ) ≤ s) (hy : s ≤ ((3910 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) : + Finv s I11 < 0 := + cell_neg I11 3908 3910 4096 100000000000 (fun r => if r = 2 then 193802857665 else if r = 9 then 814535858265 else if r = 17 then 1494768866317 else 0) (fun r => if r = 1 then 99999999999 else if r = 8 then 727176051638 else if r = 9 then 813662441031 else 0) (by norm_num) (by norm_num) + (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) s hx hy +theorem cell11_29 (s : ℝ) (hx : ((3910 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ) ≤ s) (hy : s ≤ ((3912 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) : + Finv s I11 < 0 := + cell_neg I11 3910 3912 4096 100000000000 (fun r => if r = 2 then 193868461493 else if r = 9 then 815410213056 else if r = 17 then 1496838167982 else 0) (fun r => if r = 1 then 99999999999 else if r = 8 then 727914766490 else if r = 9 then 814535858262 else 0) (by norm_num) (by norm_num) + (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) s hx hy +theorem cell11_30 (s : ℝ) (hx : ((3912 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ) ≤ s) (hy : s ≤ ((3914 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) : + Finv s I11 < 0 := + cell_neg I11 3912 3914 4096 100000000000 (fun r => if r = 2 then 193934087529 else if r = 9 then 816285506414 else if r = 17 then 1498910334309 else 0) (fun r => if r = 1 then 99999999999 else if r = 8 then 728654231779 else if r = 9 then 815410213053 else 0) (by norm_num) (by norm_num) + (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) s hx hy +theorem cell11_31 (s : ℝ) (hx : ((3914 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ) ≤ s) (hy : s ≤ ((3916 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) : + Finv s I11 < 0 := + cell_neg I11 3914 3916 4096 100000000000 (fun r => if r = 2 then 193999735779 else if r = 9 then 817161739346 else if r = 17 then 1500985369266 else 0) (fun r => if r = 1 then 99999999999 else if r = 8 then 729394448267 else if r = 9 then 816285506411 else 0) (by norm_num) (by norm_num) + (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) s hx hy +theorem cell11_32 (s : ℝ) (hx : ((3916 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ) ≤ s) (hy : s ≤ ((3917 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) : + Finv s I11 < 0 := + cell_neg I11 3916 3917 4096 100000000000 (fun r => if r = 2 then 194032568237 else if r = 9 then 817600208467 else if r = 17 then 1502023963721 else 0) (fun r => if r = 1 then 99999999999 else if r = 8 then 730135416717 else if r = 9 then 817161739343 else 0) (by norm_num) (by norm_num) + (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) s hx hy +theorem cell11_33 (s : ℝ) (hx : ((3917 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ) ≤ s) (hy : s ≤ ((3918 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) : + Finv s I11 < 0 := + cell_neg I11 3917 3918 4096 100000000000 (fun r => if r = 2 then 194065406252 else if r = 9 then 818038912861 else if r = 17 then 1503063276823 else 0) (fun r => if r = 1 then 99999999999 else if r = 8 then 730506183167 else if r = 9 then 817600208464 else 0) (by norm_num) (by norm_num) + (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) s hx hy +theorem cell11_34 (s : ℝ) (hx : ((3918 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ) ≤ s) (hy : s ≤ ((3919 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) : + Finv s I11 < 0 := + cell_neg I11 3918 3919 4096 100000000000 (fun r => if r = 2 then 194098249824 else if r = 9 then 818477852652 else if r = 17 then 1504103309069 else 0) (fun r => if r = 1 then 99999999999 else if r = 8 then 730877137893 else if r = 9 then 818038912858 else 0) (by norm_num) (by norm_num) + (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) s hx hy +theorem cell11_35 (s : ℝ) (hx : ((3919 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ) ≤ s) (hy : s ≤ ((3920 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) : + Finv s I11 < 0 := + cell_neg I11 3919 3920 4096 100000000000 (fun r => if r = 2 then 194131098954 else if r = 9 then 818917027968 else if r = 17 then 1505144060957 else 0) (fun r => if r = 1 then 99999999999 else if r = 8 then 731248280993 else if r = 9 then 818477852649 else 0) (by norm_num) (by norm_num) + (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) (by decide +kernel) s hx hy +theorem I11_neg (s : ℝ) (h0 : 0 ≤ s) (h1 : s ≤ ((3920 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) : Finv s I11 < 0 := by + rcases le_total s (((980 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) with h2 | h2 + · exact cell11_0 s (by rw [Nat.cast_zero, zero_div]; exact h0) h2 + · rcases le_total s (((1470 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) with h3 | h3 + · exact cell11_1 s h2 h3 + · rcases le_total s (((1960 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) with h4 | h4 + · exact cell11_2 s h3 h4 + · rcases le_total s (((2450 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) with h5 | h5 + · exact cell11_3 s h4 h5 + · rcases le_total s (((2695 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) with h6 | h6 + · exact cell11_4 s h5 h6 + · rcases le_total s (((2940 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) with h7 | h7 + · exact cell11_5 s h6 h7 + · rcases le_total s (((3185 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) with h8 | h8 + · exact cell11_6 s h7 h8 + · rcases le_total s (((3307 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) with h9 | h9 + · exact cell11_7 s h8 h9 + · rcases le_total s (((3430 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) with h10 | h10 + · exact cell11_8 s h9 h10 + · rcases le_total s (((3491 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) with h11 | h11 + · exact cell11_9 s h10 h11 + · rcases le_total s (((3552 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) with h12 | h12 + · exact cell11_10 s h11 h12 + · rcases le_total s (((3613 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) with h13 | h13 + · exact cell11_11 s h12 h13 + · rcases le_total s (((3675 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) with h14 | h14 + · exact cell11_12 s h13 h14 + · rcases le_total s (((3705 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) with h15 | h15 + · exact cell11_13 s h14 h15 + · rcases le_total s (((3736 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) with h16 | h16 + · exact cell11_14 s h15 h16 + · rcases le_total s (((3766 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) with h17 | h17 + · exact cell11_15 s h16 h17 + · rcases le_total s (((3797 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) with h18 | h18 + · exact cell11_16 s h17 h18 + · rcases le_total s (((3812 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) with h19 | h19 + · exact cell11_17 s h18 h19 + · rcases le_total s (((3827 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) with h20 | h20 + · exact cell11_18 s h19 h20 + · rcases le_total s (((3842 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) with h21 | h21 + · exact cell11_19 s h20 h21 + · rcases le_total s (((3858 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) with h22 | h22 + · exact cell11_20 s h21 h22 + · rcases le_total s (((3873 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) with h23 | h23 + · exact cell11_21 s h22 h23 + · rcases le_total s (((3881 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) with h24 | h24 + · exact cell11_22 s h23 h24 + · rcases le_total s (((3889 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) with h25 | h25 + · exact cell11_23 s h24 h25 + · rcases le_total s (((3896 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) with h26 | h26 + · exact cell11_24 s h25 h26 + · rcases le_total s (((3900 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) with h27 | h27 + · exact cell11_25 s h26 h27 + · rcases le_total s (((3904 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) with h28 | h28 + · exact cell11_26 s h27 h28 + · rcases le_total s (((3908 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) with h29 | h29 + · exact cell11_27 s h28 h29 + · rcases le_total s (((3910 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) with h30 | h30 + · exact cell11_28 s h29 h30 + · rcases le_total s (((3912 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) with h31 | h31 + · exact cell11_29 s h30 h31 + · rcases le_total s (((3914 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) with h32 | h32 + · exact cell11_30 s h31 h32 + · rcases le_total s (((3916 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) with h33 | h33 + · exact cell11_31 s h32 h33 + · rcases le_total s (((3917 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) with h34 | h34 + · exact cell11_32 s h33 h34 + · rcases le_total s (((3918 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) with h35 | h35 + · exact cell11_33 s h34 h35 + · rcases le_total s (((3919 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ)) with h36 | h36 + · exact cell11_34 s h35 h36 + · exact cell11_35 s h36 h1 + +/-- t >= 176/4096: the invoice F of EVERY native at the floor with the 1|1 caller (thin 4) is negative -/ +theorem split11_ceiling (t : ℝ) (ht : (176 : ℝ) / 4096 ≤ t) (ht1 : t ≤ 1) : Finv (1 - t) I11 < 0 := by + apply I11_neg (1 - t) (by linarith) + have : ((3920 : ℕ) : ℝ) / ((4096 : ℕ) : ℝ) = 1 - 176 / 4096 := by norm_num + rw [this]; linarith + +/-- UNCONDITIONAL-NUMERICS instance of the ceiling theorem: argmax split 2|2, thin >= 4, any native meeting the floor: + F(t) < 0 for t >= 141/4096 (class lemmas hB/hth and the native floor hN stay hypotheses; no NumCert needed). -/ +theorem ceiling_split22 (c : InClass 4) (ha : c.a = 2) (hb : c.b = 2) (n : Inv) + (hN : ∀ s : ℝ, 0 ≤ s → s ≤ 1 → Finv s n ≤ -Nfl s) (t : ℝ) (ht : (141 : ℝ) / 4096 ≤ t) (ht1 : t ≤ 1) : + Finv (1 - t) (invoice c.ci n (c.a + c.b)) < 0 := by + have hs0 : (0 : ℝ) ≤ 1 - t := by linarith + have hs1 : 1 - t ≤ 1 := by linarith + rw [invoice_F] + have h1 := c.hB (1 - t) hs0 hs1 + have h2 := hN (1 - t) hs0 hs1 + have h3 : ((c.a + c.b : ℕ) : ℝ) * Finv (1 - t) n ≤ ((c.a + c.b : ℕ) : ℝ) * (-Nfl (1 - t)) := + mul_le_mul_of_nonneg_left h2 (Nat.cast_nonneg _) + have h4 := FBc_th_mono c.a c.b c.hth (1 - t) + have h5 := split22_ceiling t ht ht1 + rw [I22_F] at h5 + rw [ha, hb] at h1 h3 h4 ⊢ + push_cast at h3 ⊢ + norm_num at h3 h5 ⊢ + linarith + +/-- CORRECTED argmax split 1|1 (k = 2, thin >= 4, any native meeting the floor): F(t) < 0 for t >= 176/4096 = .04297 (kernel-checked, 36 cells; + the sharp value .0419448764 is the certified root, NumCert). Class lemmas hB/hth and the native floor hN stay hypotheses. -/ +theorem ceiling_split11 (c : InClass 4) (ha : c.a = 1) (hb : c.b = 1) (n : Inv) + (hN : ∀ s : ℝ, 0 ≤ s → s ≤ 1 → Finv s n ≤ -Nfl s) (t : ℝ) (ht : (176 : ℝ) / 4096 ≤ t) (ht1 : t ≤ 1) : + Finv (1 - t) (invoice c.ci n (c.a + c.b)) < 0 := by + have hs0 : (0 : ℝ) ≤ 1 - t := by linarith + have hs1 : 1 - t ≤ 1 := by linarith + rw [invoice_F] + have h1 := c.hB (1 - t) hs0 hs1 + have h2 := hN (1 - t) hs0 hs1 + have h3 : ((c.a + c.b : ℕ) : ℝ) * Finv (1 - t) n ≤ ((c.a + c.b : ℕ) : ℝ) * (-Nfl (1 - t)) := + mul_le_mul_of_nonneg_left h2 (Nat.cast_nonneg _) + have h4 := FBc_th_mono c.a c.b c.hth (1 - t) + have h5 := split11_ceiling t ht ht1 + rw [I11_F] at h5 + rw [ha, hb] at h1 h3 h4 ⊢ + push_cast at h3 ⊢ + norm_num at h3 h5 ⊢ + linarith + +#print axioms invoice_F +#print axioms natFloor_F +#print axioms FB_eq +#print axioms ceiling +#print axioms ceiling4 +#print axioms ceiling3 +#print axioms rp_le_nat +#print axioms rp_ge_nat +#print axioms I22_F +#print axioms split22_ceiling +#print axioms ceiling_split22 +#print axioms callerG_F +#print axioms callerG_S +#print axioms callerG_eq_caller_F +#print axioms split11_ceiling +#print axioms ceiling_split11 +#print axioms I89_F +#print axioms control_bracket + +end JointCeiling diff --git a/research/p104-tiered-ceiling/lean/Nov15/JointCeiling.md b/research/p104-tiered-ceiling/lean/Nov15/JointCeiling.md new file mode 100644 index 0000000000..9672a4cb33 --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/JointCeiling.md @@ -0,0 +1,21 @@ +# JointCeiling.lean: Joint (caller, native) ceiling, CORRECTED +Imports Nov15.CallerCost + Mathlib. About 12 s, 2.9 GB. 18 `#print axioms` all within [propext, Classical.choice, Quot.sound]; no sorry, no native_decide (`decide +kernel` = kernel evaluation only). The rational-cell data are produced by scripts that are not shipped; Lean re-checks every cell. +Convention: F(s) = sum (T-P) r^s, s = 1-t. + +## WITHDRAWN +- **The old statement "kappa <= .0336321541 (thin 4) / .0400007313 (thin 3), argmax 2|2" is WITHDRAWN.** Reason (internal audit): the generating script overcharged every arm of length 1 by 208 one-stage lines (P[8]) -- two lines per port, 104 ports x 2 -- breaking the ledger S = 3408(a+b) - 208. The argmax is 1|1 (k = 2), not 2|2, and the R1 NumCert list built from that script is invalid for arms of 1. +- tbar4 = .0336321541, tbar3 = .0400007313 are removed from the file. + +## Proved (kernel) +- `invoice_F`, `Fh_mono`, `natFloor`, `natFloor_F` (Nfl = 400*8^s + 16 + 88(2-2^s)): unchanged. +- **Correction (a).** `FBc a b th s = FB a b th s + 208*8^s*(#arms of 1)`; `callerG a b th` = ledger-correct caller histogram (a,b >= 1; P[8] = 384 + 16(a+b) - 208 #arms-of-1). `callerG_F`: F(callerG) = FBc for all a,b >= 1. `callerG_S`: **S(callerG a b 4) = 3408(a+b) - 208 for ALL a,b >= 1** (the ledger law; with the floor native S = -3216/call this is 192k - 208 = 176, 368, 560 at 1|1, 1|2, 2|2). `FBc_two`, `callerG_eq_caller_F`: for a,b >= 2 FBc = FB and callerG has the same F as CallerCost.caller (and FB_eq / reproduction of #7113 / S_caller are untouched), so the a,b >= 2 agreement stands. (`FB_eq`, `FB_th_mono` kept.) +- **Ceiling theorems** (`ceiling`, `ceiling4`, `ceiling3`) now run on FBc; tbar4 = .0419448764 (rounded up from the certified root .041944876391), tbar3 = .0681203280 (th3 B-form-A class only). +- **(c) Kernel-checked numerics:** `split22_ceiling` / `ceiling_split22` (2|2, t >= 141/4096, 28 cells; unaffected by the correction) and NEW `split11_ceiling` / `ceiling_split11`: the corrected argmax 1|1, thin >= 4, any floor native: F(t) < 0 for t >= 176/4096 = .04297 (36 rational cells, DEC = 1e11, q = 4096; the sharp root .0419448764 is not reachable by 4096-grid cells, it is in NumCert). `control_bracket` (C(8|9) = #7113 caller, F(.0204) > 0 > F(.0205)) unchanged. + +## Hypotheses (explicit, named) +1. `InClass.hB`: B-form per-split optimality pointwise in F on [0,1] (justified by a tail-swap/join majorization + Karamata argument, phi concave; finite checks 58,873 schedules and 360,844 B layouts; the audit found it sound for B ports). It holds on B ports. **It FAILS on A ports for the true sign-floor masks (centre-drop case, 6,009 / 5,879 failing layouts)**, which is why the ceiling is stated for the built-type class (A = 4 QUERY, B-form masks). `hth`: th >= th0 (4 = A ports use 4 QUERY sign units; 3 unbuilt). `hrho`: rho >= 2 (Theorem H, + t = -1 closure, #7606 findings bundle), recorded only. +2. `hN`: F_nat <= -Nfl on [0,1] (whole-floor note). Not re-proved. +3. `NumCert th0 tbar` (regenerated): for every split a|b (a,b >= 1), 0 <= s <= 1-tbar: FBc a b th0 s - (a+b) Nfl s < 0. Source: an external interval-arithmetic script (1|1 root, 1|b for b = 2..59 by interval cover, tail k >= 61 by U plus 208*8^s with U < 0 and U' < 0, a,b >= 2 splits unchanged since FBc = FB there). Its output: th4 1|1 kbar .041944876391 cert True, 1|b True, tail True; th3 .068120327915. Not in the kernel: ~1,800 pairs of 40-digit interval covers; the tail U >= F Jensen/MVT step (R1) is unaudited (audit conditions). + +## Theorem as restated (paper) +For every rho = 2 nested two-arm caller (arms a,b >= 1, meeting only in hubs, host calls t != -1) with A ports at 4 QUERY sign units and B-form masks, composed with any native at the whole-floor per-call floor: kappa <= .0419448764, peak at 1|1 (k = 2). Conditions: [H-centre] (no line crosses the centre at h <= 4), [H-odd] (a B sign unit costs >= psi(1)), Theorem H + t = -1 closure (quoted), the R1 tail step (hypothesis, in NumCert), hN, and realisability of arms of 1 / k = 2 (no root built; Floor Lemma does not cover an innermost-only arm). Outside the class: trees, multi-centre, shared own roles. The .0681203279 figure (thin-3 masks) is only "scanned, conditional" for the true sign-floor class (audit); the Lean `ceiling3` certifies only the th3 B-form-A class under hB. diff --git a/research/p104-tiered-ceiling/lean/Nov15/JunkLB2.lean b/research/p104-tiered-ceiling/lean/Nov15/JunkLB2.lean new file mode 100644 index 0000000000..d9d034ea16 --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/JunkLB2.lean @@ -0,0 +1,1188 @@ +/- +BIG-JUNKLB2 (internal notes), T1 g9 pricing (class M): charging every move at g9 = h_9, except a Y main's first move + (out of chart 0, never on a pair chain), never exceeds the real I1 cost; the gap for Y_p is + l(d_1) = f(8) - f(d_1) - f(9-d_1) ≥ 0. Hence Σ_{junk pairs} dist_{g9}(A_q → G_p) ≤ public cost. +T3 slot lemma (level 7): |D| ≤ rank{x_p : p ∈ D} + |Z|, with the T2 facts as explicit hypotheses. +T4 departer law, CORRECTED SCOPE (GAPMAP): arrivals = ALL arrivals at c, owned included; + dim π(Arr_c) ≤ #public departers + #owned arrivals + #Y enders. Each departer stop costs ≥ f(2). + The public-only version is false in the same model (`T4_public_only_false`). +(Nov 16): T1 linked to registers (`Net.T1_cost`, `Net.T1_full`: Σ move charges ≤ public +cost under JunkM op semantics); T2 proved from level-k op semantics (`T2_run`: complementarity, +independence, expansion existence) and discharged in T3 (`slot_lemma_T2`, `slot_lemma_run`). +Self-contained: h / gaps / hsum / two_point / Net are copied from Nov15/JunkM.lean. +-/ +import Mathlib.Analysis.SpecialFunctions.Log.NegMulLog +import Mathlib.Analysis.Convex.Slope +import Mathlib.LinearAlgebra.FiniteDimensional.Lemmas +import Mathlib.LinearAlgebra.StdBasis +import Mathlib.LinearAlgebra.Dimension.OrzechProperty + +open Finset + +set_option linter.unusedSectionVars false +set_option linter.unusedSimpArgs false + +namespace JunkLB2 + +/-! ## Costs (copied from JunkM, I1) -/ + +section Cost + +variable (f : ℝ → ℝ) + +/-- `h_e(a,b) = f(e-a) - f(b-a) - f(e-b)`. -/ +def h (e a b : ℝ) : ℝ := f (e - a) - f (b - a) - f (e - b) + +def gaps : List ℝ → ℝ + | a :: b :: t => f (b - a) + gaps (b :: t) + | _ => 0 + +/-- `Σ h_e(d_i, d_{i+1})` along a dim chain. -/ +def hsum (e : ℝ) : List ℝ → ℝ + | a :: b :: t => h f e a b + hsum e (b :: t) + | _ => 0 + +/-- telescoping with an arbitrary pricing level `e` (the chain need not end at `e`): +`Σ h_e(d_i,d_{i+1}) = f(e - d_0) - f(e - last) - Σ f(gaps)`. -/ +theorem hsum_tele (e : ℝ) : ∀ (d0 : ℝ) (ds : List ℝ), + hsum f e (d0 :: ds) = + f (e - d0) - f (e - (d0 :: ds).getLast (List.cons_ne_nil _ _)) - gaps f (d0 :: ds) + | d0, [] => by simp [hsum, gaps] + | d0, b :: t => by + have ih := hsum_tele e b t + rw [List.getLast_cons (List.cons_ne_nil _ _)] + simp only [hsum, gaps, h] at ih ⊢ + rw [ih]; ring + +end Cost + +/-- `f(r) = r log r`. -/ +noncomputable def fL (r : ℝ) : ℝ := r * Real.log r + +lemma fL_convex : ConvexOn ℝ (Set.Ici (0 : ℝ)) fL := Real.convexOn_mul_log + +/-- two-point majorisation for a convex function on `[0,∞)` (copied from JunkM). -/ +lemma two_point {f : ℝ → ℝ} (cvx : ConvexOn ℝ (Set.Ici (0 : ℝ)) f) {lo hi y z : ℝ} (h0 : 0 ≤ lo) + (hlt : lo < hi) (hy1 : lo ≤ y) (hy2 : y ≤ hi) (hz1 : lo ≤ z) (hz2 : z ≤ hi) + (hs : y + z = lo + hi) : f y + f z ≤ f lo + f hi := by + have hD : 0 < hi - lo := by linarith + have hlo : lo ∈ Set.Ici (0:ℝ) := h0 + have hhi : hi ∈ Set.Ici (0:ℝ) := by simp; linarith + have hy := cvx.2 hlo hhi + (div_nonneg (by linarith) hD.le : (0:ℝ) ≤ (hi - y) / (hi - lo)) + (div_nonneg (by linarith) hD.le : (0:ℝ) ≤ (y - lo) / (hi - lo)) (by field_simp; ring) + have hz := cvx.2 hlo hhi + (div_nonneg (by linarith) hD.le : (0:ℝ) ≤ (hi - z) / (hi - lo)) + (div_nonneg (by linarith) hD.le : (0:ℝ) ≤ (z - lo) / (hi - lo)) (by field_simp; ring) + simp only [smul_eq_mul] at hy hz + have ey : (hi - y) / (hi - lo) * lo + (y - lo) / (hi - lo) * hi = y := by field_simp; ring + have ez : (hi - z) / (hi - lo) * lo + (z - lo) / (hi - lo) * hi = z := by field_simp; ring + rw [ey] at hy; rw [ez] at hz + have e1 : (hi - y) / (hi - lo) + (hi - z) / (hi - lo) = 1 := by field_simp; linarith + have e2 : (y - lo) / (hi - lo) + (z - lo) / (hi - lo) = 1 := by field_simp; linarith + have : f y + f z ≤ ((hi - y) / (hi - lo) + (hi - z) / (hi - lo)) * f lo + + ((y - lo) / (hi - lo) + (z - lo) / (hi - lo)) * f hi := by linarith + rw [e1, e2] at this; linarith + +lemma fL0 : fL 0 = 0 := by simp [fL] +lemma fL1 : fL 1 = 0 := by simp [fL] + +/-- every ascending move strictly below the final dim costs at least `κ = f(2) = 2 log 2`: +`h_e(a,b) ≥ f(2)` when `b - a ≥ 1` and `e - b ≥ 1` (T4's "each departer stop costs ≥ f(2)"). -/ +theorem kappa_le (e a b : ℝ) (hab : 1 ≤ b - a) (hbe : 1 ≤ e - b) : fL 2 ≤ h fL e a b := by + have cvx := fL_convex + set x := b - a; set y := e - b + have hxy : e - a = x + y := by simp only [x, y]; ring + -- f(x) + f(1+y) ≤ f(1) + f(x+y) + have s1 := two_point cvx (lo := 1) (hi := x + y) (y := x) (z := 1 + y) + (by norm_num) (by linarith) hab (by linarith) (by linarith) (by linarith) (by ring) + -- f(y) + f(2) ≤ f(1) + f(1+y) + have s2 := two_point cvx (lo := 1) (hi := 1 + y) (y := y) (z := 2) + (by norm_num) (by linarith) hbe (by linarith) (by norm_num) (by linarith) (by ring) + simp only [h, hxy]; rw [fL1] at s1 s2; linarith + +/-- `g9(a,b) ≥ 0` for `a ≤ b ≤ 9`. -/ +lemma g9_nonneg (a b : ℝ) (hab : a ≤ b) (hb : b ≤ 9) : 0 ≤ h fL 9 a b := by + have := two_point fL_convex (lo := 0) (hi := 9 - a) (y := b - a) (z := 9 - b) + rcases (show a = 9 ∨ a < 9 by + rcases lt_or_eq_of_le (hab.trans hb) with h' | h' <;> [exact Or.inr h'; exact Or.inl h']) with + rfl | ha + · have : b = 9 := le_antisymm hb hab + subst this; simp [h, fL0] + · have := this le_rfl (by linarith) (by linarith) (by linarith) (by linarith) (by linarith) + (by ring) + simp only [h]; rw [fL0] at this; linarith + +/-! ## T1. g9 pricing (class M) -/ + +section T1 + +/-- **T1, Y main.** For `Y_p` with dim chain `0 < d_1 < … < d_k = 8`, the real I1 cost +`Σ h_8` equals the g9 charge on every move but the first, plus `l(d_1) = f(8) - f(d_1) - f(9 - d_1)`. -/ +theorem T1_Y (f : ℝ → ℝ) (hf0 : f 0 = 0) (hf1 : f 1 = 0) (d1 : ℝ) (rest : List ℝ) + (hlast : (d1 :: rest).getLast (List.cons_ne_nil _ _) = 8) : + hsum f 8 (0 :: d1 :: rest) = hsum f 9 (d1 :: rest) + (f 8 - f d1 - f (9 - d1)) := by + have e1 : hsum f 8 (0 :: d1 :: rest) = h f 8 0 d1 + hsum f 8 (d1 :: rest) := rfl + rw [e1, hsum_tele f 8 d1 rest, hsum_tele f 9 d1 rest, hlast] + have a1 : (8:ℝ) - 8 = 0 := by norm_num + have a2 : (9:ℝ) - 8 = 1 := by norm_num + simp only [h, a1, a2, hf0, hf1, sub_zero]; ring + +/-- the T1 slack `l(d) = f(8) - f(d) - f(9-d) ≥ 0` for `1 ≤ d ≤ 8` (and `l(1) = l(8) = 0`). -/ +theorem l_nonneg (d : ℝ) (h1 : 1 ≤ d) (h8 : d ≤ 8) : 0 ≤ fL 8 - fL d - fL (9 - d) := by + have := two_point fL_convex (lo := 1) (hi := 8) (y := d) (z := 9 - d) + (by norm_num) (by norm_num) h1 h8 (by linarith) (by linarith) (by ring) + rw [fL1] at this; linarith + +lemma l_one : fL 8 - fL 1 - fL (9 - 1) = 0 := by norm_num [fL1] + +/-- **T1, per register.** Charged ≤ real for a Y main (`0 :: d_1 :: … :: 8`, first move uncharged); +for a register ending at V (dim 9) the charge is its real cost by definition (`hsum fL 9`). -/ +theorem T1_Y_le (d1 : ℝ) (rest : List ℝ) (h1 : 1 ≤ d1) (h8 : d1 ≤ 8) + (hlast : (d1 :: rest).getLast (List.cons_ne_nil _ _) = 8) : + hsum fL 9 (d1 :: rest) ≤ hsum fL 8 (0 :: d1 :: rest) := by + rw [T1_Y fL fL0 fL1 d1 rest hlast]; linarith [l_nonneg d1 h1 h8] + +/-! ### The path bound with g9 everywhere (copy of JunkM's `Net`, no free moves) -/ + +attribute [local instance] Classical.propDecidable + +variable {C XP YP Mv : Type*} [PartialOrder C] [Fintype XP] [Fintype YP] [Fintype Mv] + +structure Net (C XP YP Mv : Type*) [PartialOrder C] where + inS : XP → C → Prop + inP : YP → C → Prop + monoS : ∀ q s s', s ≤ s' → inS q s → inS q s' + antiP : ∀ p t t', t ≤ t' → inP p t' → inP p t + A : XP → C + G : YP → C + hA : ∀ q, inS q (A q) + hG : ∀ p, inP p (G p) + src : Mv → C + tgt : Mv → C + hlt : ∀ m, src m < tgt m + +namespace Net + +variable (N : Net C XP YP Mv) + +noncomputable def nS (s : C) : ℕ := (univ.filter fun q => N.inS q s).card +noncomputable def mP (t : C) : ℕ := (univ.filter fun p => N.inP p t).card + +def Chain : C → List Mv → C → Prop + | a, [], b => a = b + | a, m :: ms, b => N.src m = a ∧ Chain (N.tgt m) ms b + +lemma chain_bounds : ∀ (a : C) (ℓ : List Mv) (b : C), N.Chain a ℓ b → + ∀ m ∈ ℓ, a ≤ N.src m ∧ N.tgt m ≤ b + | a, [], b, _, m, hm => absurd hm (List.not_mem_nil) + | a, m' :: ms, b, ⟨hs, hc⟩, m, hm => by + have hab : ∀ x ∈ ms, N.tgt m' ≤ N.src x ∧ N.tgt x ≤ b := chain_bounds _ ms b hc + have hend : N.tgt m' ≤ b := by + cases ms with + | nil => exact le_of_eq hc + | cons x xs => exact (le_of_lt (N.hlt x)).trans' ((hab x (by simp)).1) |>.trans (hab x (by simp)).2 + rcases List.mem_cons.mp hm with rfl | hm + · exact ⟨le_of_eq hs.symm, hend⟩ + · have := hab m hm + exact ⟨(le_of_eq hs.symm).trans ((le_of_lt (N.hlt m')).trans this.1), this.2⟩ + +lemma chain_nodup : ∀ (a : C) (ℓ : List Mv) (b : C), N.Chain a ℓ b → ℓ.Nodup + | a, [], b, _ => List.nodup_nil + | a, m :: ms, b, ⟨_, hc⟩ => by + refine List.nodup_cons.mpr ⟨fun hm => ?_, chain_nodup _ ms b hc⟩ + have := (N.chain_bounds _ ms b hc m hm).1 + exact absurd (lt_of_lt_of_le (N.hlt m) this) (lt_irrefl _) + +noncomputable def wt (c : C → C → ℝ) (m : Mv) : ℝ := + c (N.src m) (N.tgt m) / ((N.nS (N.src m) : ℝ) * N.mP (N.tgt m)) + +lemma users_card (P : Finset (YP × XP)) (path : YP × XP → List Mv) + (hpath : ∀ π ∈ P, N.Chain (N.A π.2) (path π) (N.G π.1)) (m : Mv) : + (P.filter fun π => m ∈ path π).card ≤ N.mP (N.tgt m) * N.nS (N.src m) := by + rw [mP, nS, ← card_product] + apply card_le_card + intro π hπ + rw [mem_filter] at hπ + have hb := N.chain_bounds _ _ _ (hpath π hπ.1) m hπ.2 + simp only [mem_product, mem_filter, mem_univ, true_and] + exact ⟨N.antiP π.1 _ _ hb.2 (N.hG π.1), N.monoS π.2 _ _ hb.1 (N.hA π.2)⟩ + +def ChartChain : C → List C → C → Prop + | a, [], b => a = b + | a, t :: ts, b => a < t ∧ ChartChain t ts b + +noncomputable def cw (c : C → C → ℝ) : C → List C → ℝ + | _, [] => 0 + | a, t :: ts => c a t / ((N.nS a : ℝ) * N.mP t) + cw c t ts + +/-- the shortest-path value `dist(a → b)` in the chart graph. -/ +noncomputable def dist (c : C → C → ℝ) (a b : C) : ℝ := + sInf {x | ∃ l, ChartChain a l b ∧ N.cw c a l = x} + +lemma cw_nonneg (c : C → C → ℝ) (hc0 : ∀ s t, 0 ≤ c s t) : ∀ a l, 0 ≤ N.cw c a l + | _, [] => le_rfl + | a, t :: ts => add_nonneg (div_nonneg (hc0 _ _) (by positivity)) (cw_nonneg c hc0 t ts) + +lemma chain_to_chart (c : C → C → ℝ) : ∀ (a : C) (ℓ : List Mv) (b : C), N.Chain a ℓ b → + ChartChain a (ℓ.map N.tgt) b ∧ N.cw c a (ℓ.map N.tgt) = (ℓ.map (N.wt c)).sum + | a, [], b, h => ⟨h, rfl⟩ + | a, m :: ms, b, ⟨hs, hc⟩ => by + obtain ⟨h1, h2⟩ := chain_to_chart c _ ms b hc + refine ⟨⟨hs ▸ N.hlt m, h1⟩, ?_⟩ + simp only [List.map_cons, cw, List.sum_cons, h2, wt, hs] + +lemma dist_le (c : C → C → ℝ) (hc0 : ∀ s t, 0 ≤ c s t) {a b : C} {ℓ : List Mv} + (h : N.Chain a ℓ b) : N.dist c a b ≤ (ℓ.map (N.wt c)).sum := by + obtain ⟨h1, h2⟩ := N.chain_to_chart c a ℓ b h + exact csInf_le ⟨0, fun x ⟨l, _, hx⟩ => hx ▸ N.cw_nonneg c hc0 a l⟩ ⟨_, h1, h2⟩ + +/-- the path bound without free moves: if every USED move is charged `w m ≥ c(src,tgt)`, then +`Σ_pairs dist ≤ Σ_m w m`. -/ +theorem bound0 (c : C → C → ℝ) (w : Mv → ℝ) (P : Finset (YP × XP)) (path : YP × XP → List Mv) + (hpath : ∀ π ∈ P, N.Chain (N.A π.2) (path π) (N.G π.1)) + (hc0 : ∀ s t, 0 ≤ c s t) (hw0 : ∀ m, 0 ≤ w m) + (hpay : ∀ m, (∃ π ∈ P, m ∈ path π) → c (N.src m) (N.tgt m) ≤ w m) : + ∑ π ∈ P, N.dist c (N.A π.2) (N.G π.1) ≤ ∑ m, w m := by + have s1 : ∑ π ∈ P, N.dist c (N.A π.2) (N.G π.1) ≤ ∑ π ∈ P, ((path π).map (N.wt c)).sum := + sum_le_sum fun π hπ => N.dist_le c hc0 (hpath π hπ) + have s2 : ∑ π ∈ P, ((path π).map (N.wt c)).sum + = ∑ m, ((P.filter fun π => m ∈ path π).card : ℝ) * N.wt c m := by + have e1 : ∀ π ∈ P, ((path π).map (N.wt c)).sum + = ∑ m, if m ∈ path π then N.wt c m else 0 := by + intro π hπ + rw [← List.sum_toFinset _ (N.chain_nodup _ _ _ (hpath π hπ)), ← sum_filter] + congr 1; ext m; simp + rw [sum_congr rfl e1, sum_comm] + refine sum_congr rfl fun m _ => ?_ + rw [← sum_filter, sum_const, nsmul_eq_mul] + have s3 : ∀ m, ((P.filter fun π => m ∈ path π).card : ℝ) * N.wt c m ≤ w m := by + intro m + by_cases hu : ∃ π ∈ P, m ∈ path π + · have hcard := N.users_card P path hpath m + obtain ⟨π, hπ, hm⟩ := hu + have hpos : 0 < (P.filter fun π => m ∈ path π).card := + card_pos.mpr ⟨π, mem_filter.mpr ⟨hπ, hm⟩⟩ + have hD : (0 : ℝ) < (N.nS (N.src m) : ℝ) * N.mP (N.tgt m) := by + have : 0 < N.mP (N.tgt m) * N.nS (N.src m) := lt_of_lt_of_le hpos hcard + rw [mul_comm]; exact_mod_cast this + have hle : ((P.filter fun π => m ∈ path π).card : ℝ) ≤ (N.nS (N.src m) : ℝ) * N.mP (N.tgt m) := by + rw [mul_comm]; exact_mod_cast hcard + have : ((P.filter fun π => m ∈ path π).card : ℝ) * N.wt c m ≤ c (N.src m) (N.tgt m) := by + rw [wt, mul_div_assoc', div_le_iff₀ hD] + exact mul_le_mul_of_nonneg_left hle (hc0 _ _) |>.trans_eq' (by ring) + exact this.trans (hpay m ⟨π, hπ, hm⟩) + · have : (P.filter fun π => m ∈ path π) = ∅ := by + ext π; simp only [mem_filter, Finset.notMem_empty, iff_false, not_and] + exact fun hπ hm => hu ⟨π, hπ, hm⟩ + simp [this, hw0 m] + calc _ ≤ _ := s1 + _ = _ := s2 + _ ≤ _ := sum_le_sum fun m _ => s3 m + +/-- **T1 (class M), path form.** Chart `z` (= chart 0) holds no X port (`n(0) = 0`). Every move +not leaving `z` is charged at least `c` (with `c = g9` on dims: `g9_nonneg`, `T1_Y_le`); moves out of +`z` (Y mains' first moves, the uncharged ones) may be charged anything `≥ 0`. Then +`Σ_{junk pairs} dist_c(A_q → G_p) ≤ Σ_m w m`; combined with `Σ_m w m ≤ public cost` (per register: +`T1_Y_le` for Y mains, equality for registers ending at V) this is T1's bound. -/ +theorem T1_bound (c : C → C → ℝ) (w : Mv → ℝ) (P : Finset (YP × XP)) (path : YP × XP → List Mv) + (hpath : ∀ π ∈ P, N.Chain (N.A π.2) (path π) (N.G π.1)) + (hc0 : ∀ s t, 0 ≤ c s t) (hw0 : ∀ m, 0 ≤ w m) (z : C) (hz : ∀ q, ¬ N.inS q z) + (hcharge : ∀ m, N.src m ≠ z → c (N.src m) (N.tgt m) ≤ w m) + (cost : ℝ) (hcost : ∑ m, w m ≤ cost) : + ∑ π ∈ P, N.dist c (N.A π.2) (N.G π.1) ≤ cost := by + refine (N.bound0 c w P path hpath hc0 hw0 fun m ⟨π, hπ, hm⟩ => hcharge m ?_).trans hcost + intro hzm + have := (N.chain_bounds _ _ _ (hpath π hπ) m hm).1 + rw [hzm] at this + exact hz π.2 (N.monoS π.2 _ _ this (N.hA π.2)) + +end Net + +end T1 + +/-! ## T1, linked to registers: total move charges ≤ public cost (JunkM op semantics) -/ + +section T1link + +attribute [local instance] Classical.propDecidable + +variable {C XP YP Mv R : Type*} [PartialOrder C] [Fintype XP] [Fintype YP] [Fintype Mv] [Fintype R] + +namespace Net + +variable (N : Net C XP YP Mv) + +lemma chain_append : ∀ (a : C) (ℓ : List Mv) (b : C) (m : Mv), N.Chain a ℓ b → N.src m = b → + N.Chain a (ℓ ++ [m]) (N.tgt m) + | a, [], b, m, h, hm => by simp only [Chain] at h; subst h; exact ⟨hm, rfl⟩ + | a, m' :: ms, b, m, ⟨hs, hc⟩, hm => ⟨hs, chain_append _ ms b m hc hm⟩ + +/-- register `i`'s moves up to time `n`, in time order: `mv t i` at each `t < n` where its chart +rises (JunkM's `mv t i`). -/ +noncomputable def movesOf (chart : ℕ → R → C) (mv : ℕ → R → Mv) (i : R) (n : ℕ) : List Mv := + ((List.range n).filter (fun t => decide (chart t i < chart (t + 1) i))).map (fun t => mv t i) + +/-- JunkM op semantics (b) charts never decrease, (c) `mv t i` goes `chart t i → chart (t+1) i` when +`i`'s chart rises: then `i`'s moves form a chain from its birth chart to its chart at time `n`. -/ +lemma movesOf_chain (chart : ℕ → R → C) (mv : ℕ → R → Mv) + (hmv : ∀ t i, chart t i < chart (t + 1) i → + N.src (mv t i) = chart t i ∧ N.tgt (mv t i) = chart (t + 1) i) + (hmono : ∀ t i, chart t i ≤ chart (t + 1) i) (i : R) : + ∀ n, N.Chain (chart 0 i) (movesOf chart mv i n) (chart n i) := by + intro n + induction n with + | zero => simp [movesOf, Chain] + | succ n ih => + by_cases hlt : chart n i < chart (n + 1) i + · have e : movesOf chart mv i (n + 1) = movesOf chart mv i n ++ [mv n i] := by + simp [movesOf, List.range_succ, List.filter_append, hlt] + obtain ⟨hs, ht⟩ := hmv n i hlt + rw [e, ← ht]; exact N.chain_append _ _ _ _ ih hs + · have e : movesOf chart mv i (n + 1) = movesOf chart mv i n := by + simp [movesOf, List.range_succ, List.filter_append, hlt] + have heq : chart (n + 1) i = chart n i := + ((hmono n i).lt_or_eq.resolve_left hlt).symm + rw [e, heq]; exact ih + +/-- the move costs along a chain telescope into `hsum` over the chain's dims. -/ +lemma chain_hsum (f : ℝ → ℝ) (e : ℝ) (dim : C → ℝ) : ∀ (a : C) (ℓ : List Mv) (b : C), N.Chain a ℓ b → + (ℓ.map fun m => h f e (dim (N.src m)) (dim (N.tgt m))).sum = + hsum f e (dim a :: ℓ.map fun m => dim (N.tgt m)) + | a, [], b, _ => by simp [hsum] + | a, m :: ms, b, ⟨hs, hc⟩ => by + simp only [List.map_cons, List.sum_cons, hsum] + rw [chain_hsum f e dim _ ms b hc, hs] + +lemma chain_last (dim : C → ℝ) : ∀ (a : C) (ℓ : List Mv) (b : C), N.Chain a ℓ b → + (dim a :: ℓ.map fun m => dim (N.tgt m)).getLast (List.cons_ne_nil _ _) = dim b + | a, [], b, hc => by simp only [Chain] at hc; subst hc; rfl + | a, m :: ms, b, ⟨_, hc⟩ => by + rw [List.map_cons, List.getLast_cons (List.cons_ne_nil _ _)] + exact chain_last dim _ ms b hc + +/-- the T1 edge price `c(s,t) = g9(dim s, dim t)` (clipped at 0, which changes nothing on real moves). -/ +noncomputable def cg (dim : C → ℕ) (s t : C) : ℝ := max (h fL 9 (dim s) (dim t)) 0 + +/-- the T1 move charge: moves out of chart `z` (= chart 0; Y mains' first moves) are uncharged, every +other move is charged `c(src, tgt)`. -/ +noncomputable def wz (dim : C → ℕ) (z : C) (m : Mv) : ℝ := + if N.src m = z then 0 else cg dim (N.src m) (N.tgt m) + +lemma cg_eq (dim : C → ℕ) (hdim : StrictMono dim) (s t : C) (hst : s < t) (ht : dim t ≤ 9) : + cg dim s t = h fL 9 (dim s) (dim t) := by + have h1 : (dim s : ℝ) ≤ dim t := by exact_mod_cast (hdim hst).le + have h2 : (dim t : ℝ) ≤ 9 := by exact_mod_cast ht + exact max_eq_left (g9_nonneg _ _ h1 h2) + +/-- a register ending at V (dim 9): its charges are at most its real cost `Σ h_9`. -/ +lemma reg_le_V (dim : C → ℕ) (hdim : StrictMono dim) (z : C) (a : C) (ℓ : List Mv) (b : C) + (hc : N.Chain a ℓ b) (hb : dim b ≤ 9) : + (ℓ.map (N.wz dim z)).sum ≤ hsum fL 9 ((dim a : ℝ) :: ℓ.map fun m => (dim (N.tgt m) : ℝ)) := by + rw [← N.chain_hsum fL 9 (fun c => (dim c : ℝ)) a ℓ b hc] + apply List.sum_le_sum + intro m hm + have hbd := N.chain_bounds a ℓ b hc m hm + have ht9 : dim (N.tgt m) ≤ 9 := (hdim.monotone hbd.2).trans hb + have hceq := cg_eq dim hdim _ _ (N.hlt m) ht9 + have h1 : (dim (N.src m) : ℝ) ≤ dim (N.tgt m) := by exact_mod_cast (hdim (N.hlt m)).le + have h2 : (dim (N.tgt m) : ℝ) ≤ 9 := by exact_mod_cast ht9 + unfold wz; split_ifs + · exact g9_nonneg _ _ h1 h2 + · exact hceq.le + +/-- a Y main (born at chart `z`, dim 0; ends at `G_p`, dim 8): charges ≤ real cost `Σ h_8` +(the first move is uncharged; `T1_Y_le`). -/ +lemma reg_le_Y (dim : C → ℕ) (hdim : StrictMono dim) (z : C) (hz0 : dim z = 0) (ℓ : List Mv) (b : C) + (hc : N.Chain z ℓ b) (hb : dim b = 8) : + (ℓ.map (N.wz dim z)).sum ≤ hsum fL 8 ((dim z : ℝ) :: ℓ.map fun m => (dim (N.tgt m) : ℝ)) := by + cases ℓ with + | nil => simp only [Chain] at hc; subst hc; omega + | cons m1 rest => + obtain ⟨hs1, hc'⟩ := hc + have hw1 : N.wz dim z m1 = 0 := by simp [wz, hs1] + have hrest : (rest.map (N.wz dim z)) = rest.map fun m => h fL 9 (dim (N.src m)) (dim (N.tgt m)) := by + apply List.map_congr_left + intro m hm + have hbd := N.chain_bounds _ rest b hc' m hm + have hpos : 0 < dim (N.src m) := by + have := hdim (lt_of_lt_of_le (hs1 ▸ N.hlt m1) hbd.1); omega + have hne : N.src m ≠ z := fun e => by rw [e] at hpos; omega + have ht9 : dim (N.tgt m) ≤ 9 := by have := hdim.monotone hbd.2; omega + simp only [wz, hne, if_false] + exact cg_eq dim hdim _ _ (N.hlt m) ht9 + rw [List.map_cons, List.sum_cons, hw1, zero_add, hrest, + N.chain_hsum fL 9 (fun c => (dim c : ℝ)) _ rest b hc', List.map_cons, hz0, Nat.cast_zero] + have hd1 : 0 < dim (N.tgt m1) := by have := hdim (hs1 ▸ N.hlt m1); omega + have hd8 : dim (N.tgt m1) ≤ 8 := by + have := hdim.monotone (show N.tgt m1 ≤ b from by + cases rest with + | nil => exact le_of_eq hc' + | cons x xs => + have hx := N.chain_bounds _ (x :: xs) b hc' x (by simp) + exact (le_of_lt (N.hlt x)).trans' hx.1 |>.trans hx.2) + omega + apply T1_Y_le + · exact_mod_cast hd1 + · exact_mod_cast hd8 + · rw [N.chain_last (fun c => (dim c : ℝ)) _ rest b hc', hb]; norm_num + +lemma list_range_filter_sum (n : ℕ) (p : ℕ → Prop) (g : ℕ → ℝ) : + (((List.range n).filter (fun t => decide (p t))).map g).sum = + ∑ t ∈ Finset.range n, if p t then g t else 0 := by + induction n with + | zero => simp + | succ n ih => + rw [List.range_succ, List.filter_append, List.map_append, List.sum_append, ih, + Finset.sum_range_succ] + by_cases hp : p n <;> simp [hp] + +/-- **T1, Σ_m w_m ≤ public cost, as a theorem.** JunkM op semantics: charts never decrease, +`mv t i` is register `i`'s move `chart t i → chart (t+1) i` when its chart rises, and the moves are +exactly these (each move is `mv t i` for exactly one rising step `t < n`). Charts carry a strictly +monotone dim (`z` = chart 0, dim 0). Model M: a Y main (`Ym`) is born at `z` and ends at dim 8, every +other register ends at V (dim 9). The public cost is `Σ_i h-sum` over each register's dim chain +(I1), with `e = 8` for Y mains and `9` otherwise. -/ +theorem T1_cost (chart : ℕ → R → C) (mv : ℕ → R → Mv) (n : ℕ) + (hmv : ∀ t i, chart t i < chart (t + 1) i → + N.src (mv t i) = chart t i ∧ N.tgt (mv t i) = chart (t + 1) i) + (hmono : ∀ t i, chart t i ≤ chart (t + 1) i) + (hsurj : ∀ m, ∃ t < n, ∃ i, chart t i < chart (t + 1) i ∧ mv t i = m) + (hinj : ∀ t t' i i', chart t i < chart (t + 1) i → chart t' i' < chart (t' + 1) i' → + mv t i = mv t' i' → t = t' ∧ i = i') + (dim : C → ℕ) (hdim : StrictMono dim) (z : C) (hz0 : dim z = 0) (Ym : Finset R) + (hY : ∀ i ∈ Ym, chart 0 i = z ∧ dim (chart n i) = 8) (hV : ∀ i ∉ Ym, dim (chart n i) = 9) : + ∑ m, N.wz dim z m ≤ ∑ i, hsum fL (if i ∈ Ym then 8 else 9) + ((dim (chart 0 i) : ℝ) :: (movesOf chart mv i n).map fun m => (dim (N.tgt m) : ℝ)) := by + have hsplit : ∑ m, N.wz dim z m = ∑ i, ((movesOf chart mv i n).map (N.wz dim z)).sum := by + have e1 : ∀ i, ((movesOf chart mv i n).map (N.wz dim z)).sum = + ∑ t ∈ Finset.range n, if chart t i < chart (t + 1) i then N.wz dim z (mv t i) else 0 := by + intro i; rw [movesOf, List.map_map]; exact list_range_filter_sum n _ _ + simp_rw [e1] + rw [Finset.sum_comm, ← Finset.sum_product (s := Finset.range n) (t := Finset.univ) + (f := fun x : ℕ × R => if chart x.1 x.2 < chart (x.1 + 1) x.2 then N.wz dim z (mv x.1 x.2) else 0), + ← Finset.sum_filter] + symm + refine Finset.sum_bij (fun x _ => mv x.1 x.2) (fun _ _ => Finset.mem_univ _) ?_ ?_ (fun _ _ => rfl) + · rintro ⟨t, i⟩ h1 ⟨t', i'⟩ h2 he + simp only [Finset.mem_filter] at h1 h2 + obtain ⟨rfl, rfl⟩ := hinj t t' i i' h1.2 h2.2 he; rfl + · intro m _ + obtain ⟨t, ht, i, hr, rfl⟩ := hsurj m + exact ⟨(t, i), by simp [ht, hr], rfl⟩ + rw [hsplit] + refine Finset.sum_le_sum fun i _ => ?_ + have hc := N.movesOf_chain chart mv hmv hmono i n + by_cases hi : i ∈ Ym + · obtain ⟨h0, h8⟩ := hY i hi + rw [if_pos hi, h0]; rw [h0] at hc + exact N.reg_le_Y dim hdim z hz0 _ _ hc h8 + · rw [if_neg hi] + exact N.reg_le_V dim hdim z _ _ _ hc (by rw [hV i hi]) + +/-- **T1 (class M), full form.** Under the hypotheses of `T1_cost`, with chart `z` holding no X port +and a move chain `A_q → G_p` for every junk pair (JunkM `hpath_of_junk`): +`Σ_{junk pairs} dist_{g9}(A_q → G_p) ≤ public cost`. -/ +theorem T1_full (chart : ℕ → R → C) (mv : ℕ → R → Mv) (n : ℕ) + (hmv : ∀ t i, chart t i < chart (t + 1) i → + N.src (mv t i) = chart t i ∧ N.tgt (mv t i) = chart (t + 1) i) + (hmono : ∀ t i, chart t i ≤ chart (t + 1) i) + (hsurj : ∀ m, ∃ t < n, ∃ i, chart t i < chart (t + 1) i ∧ mv t i = m) + (hinj : ∀ t t' i i', chart t i < chart (t + 1) i → chart t' i' < chart (t' + 1) i' → + mv t i = mv t' i' → t = t' ∧ i = i') + (dim : C → ℕ) (hdim : StrictMono dim) (z : C) (hz0 : dim z = 0) (Ym : Finset R) + (hY : ∀ i ∈ Ym, chart 0 i = z ∧ dim (chart n i) = 8) (hV : ∀ i ∉ Ym, dim (chart n i) = 9) + (hz : ∀ q, ¬ N.inS q z) + (P : Finset (YP × XP)) (path : YP × XP → List Mv) + (hpath : ∀ π ∈ P, N.Chain (N.A π.2) (path π) (N.G π.1)) : + ∑ π ∈ P, N.dist (cg dim) (N.A π.2) (N.G π.1) ≤ ∑ i, hsum fL (if i ∈ Ym then 8 else 9) + ((dim (chart 0 i) : ℝ) :: (movesOf chart mv i n).map fun m => (dim (N.tgt m) : ℝ)) := + N.T1_bound (cg dim) (N.wz dim z) P path hpath (fun _ _ => le_max_right _ _) + (fun m => by unfold wz; split_ifs; exact le_rfl; exact le_max_right _ _) z hz + (fun m hm => by simp [wz, hm]) _ + (N.T1_cost chart mv n hmv hmono hsurj hinj dim hdim z hz0 Ym hY hV) + +end Net + +end T1link + + + +/-! ## T3. Slot lemma (level 7) -/ + +section T3 + +open Module Submodule + +variable {K V Reg D C : Type*} [Field K] [AddCommGroup V] [Module K V] [FiniteDimensional K V] + [DecidableEq Reg] [Fintype D] + +/-- **T3 slot lemma.** Data at level 7 (all T2 outputs are hypotheses): +* `Cr` = crossers of level 7 with crossing rows `ρ μ`, linearly independent (T2(a)); +* `B0` = registers born at chart 0 with tokens `tok b`; `S0 = span tok(B0)`; +* `W ⊆ Cr ∩ B0` = 0-born registers jumping from chart 0 straight to dim 8/9; their crossing rows lie + in `S0` (chart 0 holds only 0-born tokens); `Z = (B0 ∩ Cr) \ W` (0-born, cross after a paid stop); +* `P` fixes every crossing row and kills the tokens of 0-born registers that never cross + (a projection onto span ρ(Cr) along the stayer tokens; it exists because these are complementary, + T2 proof — see `proj_exists`); +* for `p ∈ D`: `y p = Σ_μ A p μ • ρ μ` (T2(b)), where a non-`W` crosser has `A p μ ≠ 0` only if it + lands at `G p` (a level-7 crosser landing `≤ G_p`, dim 8, lands AT `G_p`), and `G` is injective; +* `y p = x p + e p` with `e p ∈ S0` (Y_p's token) and `0 ≠ x p ∈ X`, `X ⊓ S0 = ⊥` (X content and + 0-born tokens are different coordinates). +Then `|D| ≤ rank{x_p} + |Z|`. No directness of the `Y_p`, `p ∈ D`, is needed. -/ +theorem slot_lemma (Cr B0 W : Finset Reg) (hW : W ⊆ B0 ∩ Cr) + (ρ tok : Reg → V) (P : V →ₗ[K] V) + (hind : ∀ g : Reg → K, ∑ μ ∈ Cr, g μ • ρ μ = 0 → ∀ μ ∈ Cr, g μ = 0) + (hPρ : ∀ μ ∈ Cr, P (ρ μ) = ρ μ) + (hPst : ∀ b ∈ B0, b ∉ Cr → P (tok b) = 0) + (hWS0 : ∀ μ ∈ W, ρ μ ∈ span K (tok '' (B0 : Set Reg))) + (land : Reg → C) (G : D → C) (hG : Function.Injective G) + (y x e : D → V) (A : D → Reg → K) + (hT2b : ∀ p, y p = ∑ μ ∈ Cr, A p μ • ρ μ) + (hsupp : ∀ p, ∀ μ ∈ Cr, μ ∉ W → A p μ ≠ 0 → land μ = G p) + (hy : ∀ p, y p = x p + e p) (he : ∀ p, e p ∈ span K (tok '' (B0 : Set Reg))) + (X : Submodule K V) (hx : ∀ p, x p ∈ X) (hXS : X ⊓ span K (tok '' (B0 : Set Reg)) = ⊥) + (hx0 : ∀ p, x p ≠ 0) : + Fintype.card D ≤ finrank K (span K (Set.range x)) + ((B0 ∩ Cr) \ W).card := by + classical + set S0 := span K (tok '' (B0 : Set Reg)) with hS0 + -- step 1: every y p has a non-W crosser in its expansion + have hyW : ∀ p, ∃ μ ∈ Cr, μ ∉ W ∧ A p μ ≠ 0 := by + intro p; by_contra hcon; push Not at hcon + have hyS : y p ∈ S0 := by + rw [hT2b p] + refine Submodule.sum_mem _ fun μ hμ => ?_ + by_cases hμW : μ ∈ W + · exact Submodule.smul_mem _ _ (hWS0 μ hμW) + · rw [hcon μ hμ hμW, zero_smul]; exact Submodule.zero_mem _ + have hxS : x p ∈ S0 := by + have : x p = y p - e p := by rw [hy p]; abel + rw [this]; exact Submodule.sub_mem _ hyS (he p) + have : x p ∈ X ⊓ S0 := ⟨hx p, hxS⟩ + rw [hXS] at this + exact hx0 p ((Submodule.mem_bot K).mp this) + -- step 2: the family (y_p)_{p ∈ D} ⊔ (ρ_h)_{h ∈ W} is linearly independent + let F : D ⊕ W → V := Sum.elim y (fun h => ρ h) + have hF : LinearIndependent K F := by + rw [Fintype.linearIndependent_iff] + intro g hg + let gW : Reg → K := fun μ => if hμ : μ ∈ W then g (Sum.inr ⟨μ, hμ⟩) else 0 + let coef : Reg → K := fun μ => (∑ p, g (Sum.inl p) * A p μ) + gW μ + have hW' : ∑ h : W, g (Sum.inr h) • ρ h = ∑ μ ∈ Cr, gW μ • ρ μ := by + rw [← Finset.sum_subset (fun μ hμ => (mem_inter.mp (hW hμ)).2) + (fun μ _ hμ => by simp [gW, hμ])] + rw [← Finset.sum_attach W] + refine Finset.sum_congr rfl fun h _ => ?_ + simp [gW, h.2] + have hsum : ∑ μ ∈ Cr, coef μ • ρ μ = 0 := by + rw [← hg, Fintype.sum_sum_type] + simp only [F, Sum.elim_inl, Sum.elim_inr, hT2b, Finset.smul_sum, smul_smul, coef, add_smul, + Finset.sum_add_distrib, Finset.sum_smul] + rw [hW', Finset.sum_comm] + have hc := hind coef hsum + -- non-W crossers: only one p contributes + have hone : ∀ μ ∈ Cr, μ ∉ W → ∀ p, g (Sum.inl p) * A p μ = 0 := by + intro μ hμ hμW p + have h0 : coef μ = 0 := hc μ hμ + simp only [coef, gW, hμW, dite_false, add_zero] at h0 + by_cases hA2 : A p μ = 0 + · simp [hA2] + rw [Finset.sum_eq_single p] at h0 + · exact h0 + · intro p' _ hp' + by_cases hA : A p' μ = 0 + · simp [hA] + exact absurd (hG ((hsupp p' μ hμ hμW hA).symm.trans (hsupp p μ hμ hμW hA2))) hp' + · simp + have hD0 : ∀ p, g (Sum.inl p) = 0 := by + intro p + obtain ⟨μ, hμ, hμW, hA⟩ := hyW p + exact (mul_eq_zero.mp (hone μ hμ hμW p)).resolve_right hA + rintro (p | ⟨μ, hμW⟩) + · exact hD0 p + · have h0 : coef μ = 0 := hc μ (mem_inter.mp (hW hμW)).2 + simp only [coef, gW, hμW, dite_true, hD0, zero_mul, Finset.sum_const_zero, zero_add] at h0 + exact h0 + -- step 3: the family lies in span(P x) ⊔ E + let E : Submodule K V := span K (((B0 ∩ Cr).image fun b => P (tok b) : Finset V) : Set V) + have hPS0 : ∀ v ∈ S0, P v ∈ E := by + have : S0.map P ≤ E := by + rw [hS0, Submodule.map_span, Submodule.span_le] + rintro _ ⟨_, ⟨b, hb, rfl⟩, rfl⟩ + by_cases hbC : b ∈ Cr + · exact Submodule.subset_span (by simp only [coe_image, coe_inter]; exact ⟨b, ⟨hb, hbC⟩, rfl⟩) + · simp only [SetLike.mem_coe]; rw [hPst b hb hbC]; exact Submodule.zero_mem _ + exact fun v hv => this (Submodule.mem_map_of_mem hv) + set Sx := span K (Set.range fun p => P (x p)) + have hrange : Set.range F ⊆ (Sx ⊔ E : Submodule K V) := by + rintro _ ⟨i, rfl⟩ + rcases i with p | ⟨μ, hμW⟩ + · have hPy : P (y p) = y p := by + rw [hT2b p, map_sum] + exact Finset.sum_congr rfl fun μ hμ => by rw [map_smul, hPρ μ hμ] + show y p ∈ Sx ⊔ E + rw [← hPy, hy p, map_add] + exact Submodule.add_mem _ (Submodule.mem_sup_left (Submodule.subset_span ⟨p, rfl⟩)) + (Submodule.mem_sup_right (hPS0 _ (he p))) + · show ρ μ ∈ Sx ⊔ E + rw [← hPρ μ (mem_inter.mp (hW hμW)).2] + exact Submodule.mem_sup_right (hPS0 _ (hWS0 μ hμW)) + -- step 4: count + have h1 : Fintype.card (D ⊕ W) ≤ finrank K (Sx ⊔ E : Submodule K V) := by + rw [← finrank_span_eq_card hF] + exact Submodule.finrank_mono (Submodule.span_le.mpr hrange) + have h2 := Submodule.finrank_add_le_finrank_add_finrank Sx E + have h3 : finrank K Sx ≤ finrank K (span K (Set.range x)) := by + have : Sx = (span K (Set.range x)).map P := by + rw [Submodule.map_span, ← Set.range_comp]; rfl + rw [this]; exact Submodule.finrank_map_le _ _ + have h4 : finrank K E ≤ (B0 ∩ Cr).card := + (finrank_span_finset_le_card _).trans Finset.card_image_le + have h5 : (B0 ∩ Cr).card = W.card + ((B0 ∩ Cr) \ W).card := by + rw [add_comm, Finset.card_sdiff_add_card_eq_card hW] + rw [Fintype.card_sum, Fintype.card_coe] at h1 + omega + +/-- the projection `P` of T3 exists whenever the crossing span and the stayer-token span are +complementary (T2's proof gives exactly this). -/ +theorem proj_exists (R Q : Submodule K V) (hRQ : IsCompl R Q) : + ∃ P : V →ₗ[K] V, (∀ v ∈ R, P v = v) ∧ (∀ v ∈ Q, P v = 0) := by + refine ⟨R.subtype ∘ₗ Submodule.projectionOnto R Q hRQ, fun v hv => ?_, fun v hv => ?_⟩ + · simp [Submodule.projectionOnto_apply_of_mem_left hRQ hv] + · simp [Submodule.projectionOnto_apply_of_mem_right hRQ hv] + +end T3 + +/-! ## T2. Crossing-basis lemma (complementarity), from the level-k op semantics -/ + +section T2 + +open Module Submodule + +/-- dimension count: if `a ⊔ b = ⊤`, `dim a ≤ m`, `dim b ≤ n` and `dim V = m + n`, then `a`, `b` +are complementary and both bounds are equalities. -/ +lemma compl_of_sup {K V : Type*} [Field K] [AddCommGroup V] [Module K V] [FiniteDimensional K V] + (a b : Submodule K V) (m n : ℕ) (hsup : a ⊔ b = ⊤) (ha : finrank K a ≤ m) (hb : finrank K b ≤ n) + (hV : finrank K V = m + n) : IsCompl a b ∧ finrank K a = m ∧ finrank K b = n := by + have h := Submodule.finrank_sup_add_finrank_inf_eq a b + rw [hsup, finrank_top, hV] at h + have h0 : finrank K (a ⊓ b : Submodule K V) = 0 := by omega + refine ⟨⟨disjoint_iff.mpr (Submodule.finrank_eq_zero.mp h0), codisjoint_iff.mpr hsup⟩, by omega, + by omega⟩ + +lemma finrank_span_image_le {K V ι : Type*} [Field K] [AddCommGroup V] [Module K V] + (s : Finset ι) (f : ι → V) : finrank K (span K (f '' (s : Set ι))) ≤ s.card := by + classical + rw [← Finset.coe_image]; exact (finrank_span_finset_le_card _).trans Finset.card_image_le + +variable {K Reg : Type*} [Field K] [Fintype Reg] [DecidableEq Reg] + +/-- ops seen at level `k`: an ADD `row_i += c·row_j` (co-present, so on the same side of level `k`), +or register `i` crossing level `k` (its first move from dim `≤ k` to dim `> k`). Moves that do not +cross level `k` change neither rows nor sides, so they are omitted. -/ +inductive LOp (K Reg : Type*) + | add (i j : Reg) (c : K) + | cross (i : Reg) + +/-- rows (initial-row coordinates), registers above level `k`, crossers so far, crossing rows. -/ +structure LSt (K Reg : Type*) where + row : Reg → Reg → K + ab : Finset Reg + cr : Finset Reg + rho : Reg → Reg → K + +def lstep : LSt K Reg → LOp K Reg → LSt K Reg + | s, .add i j c => ⟨Function.update s.row i (s.row i + c • s.row j), s.ab, s.cr, s.rho⟩ + | s, .cross i => ⟨s.row, insert i s.ab, insert i s.cr, Function.update s.rho i (s.row i)⟩ + +def lrun : LSt K Reg → List (LOp K Reg) → LSt K Reg + | s, [] => s + | s, op :: ops => lrun (lstep s op) ops + +/-- legality: an ADD has `i ≠ j` (an invertible public op) and both registers on the same side of +level `k` (co-presence at one chart); a crossing register is still at dim `≤ k`. -/ +def LLegal : LSt K Reg → List (LOp K Reg) → Prop + | _, [] => True + | s, .add i j c :: ops => (i ≠ j ∧ (i ∈ s.ab ↔ j ∈ s.ab)) ∧ LLegal (lstep s (.add i j c)) ops + | s, .cross i :: ops => i ∉ s.ab ∧ LLegal (lstep s (.cross i)) ops + +/-- time 0: every register holds its own token; `B` = registers born at dim `≤ k`, the rest are +above level `k` already. -/ +def lstart (B : Finset Reg) : LSt K Reg := ⟨fun r => Pi.single r 1, univ \ B, ∅, fun _ => 0⟩ + +/-- the run invariant (for any linear `L` that kills the tokens of registers born above `k`). -/ +structure LInv {W : Type*} [AddCommGroup W] [Module K W] (B : Finset Reg) (L : (Reg → K) →ₗ[K] W) + (s : LSt K Reg) : Prop where + crB : s.cr ⊆ B + ab_iff : ∀ r, r ∈ s.ab ↔ (r ∉ B ∨ r ∈ s.cr) + up : ∀ r ∈ s.ab, L (s.row r) ∈ span K ((fun μ => L (s.rho μ)) '' (s.cr : Set Reg)) + top : span K (Set.range s.row) = ⊤ + +lemma linv_start {W : Type*} [AddCommGroup W] [Module K W] (B : Finset Reg) + (L : (Reg → K) →ₗ[K] W) (hL : ∀ r, r ∉ B → L (Pi.single r 1) = 0) : + LInv B L (lstart (K := K) B) where + crB := by simp [lstart] + ab_iff := by intro r; simp [lstart] + up := by + intro r hr + simp only [lstart, mem_sdiff, mem_univ, true_and] at hr + simp only [lstart]; rw [hL r hr]; exact Submodule.zero_mem _ + top := by + have : Set.range (fun r : Reg => (Pi.single r (1 : K) : Reg → K)) = + Set.range (Pi.basisFun K Reg) := by + congr 1; funext r; simp + simp only [lstart]; rw [this]; exact (Pi.basisFun K Reg).span_eq + +lemma linv_step {W : Type*} [AddCommGroup W] [Module K W] (B : Finset Reg) + (L : (Reg → K) →ₗ[K] W) (s : LSt K Reg) (op : LOp K Reg) (hI : LInv B L s) + (hop : match op with + | .add i j _ => i ≠ j ∧ (i ∈ s.ab ↔ j ∈ s.ab) + | .cross i => i ∉ s.ab) : + LInv B L (lstep s op) := by + cases op with + | add i j c => + obtain ⟨hij, hside⟩ := hop + refine ⟨hI.crB, hI.ab_iff, ?_, ?_⟩ + · intro r hr + simp only [lstep] at hr ⊢ + by_cases hri : r = i + · subst hri + rw [Function.update_self, map_add, map_smul] + exact Submodule.add_mem _ (hI.up r hr) (Submodule.smul_mem _ _ (hI.up j (hside.mp hr))) + · rw [Function.update_of_ne hri]; exact hI.up r hr + · rw [eq_top_iff, ← hI.top, Submodule.span_le] + rintro _ ⟨r, rfl⟩ + simp only [lstep] + set u := Function.update s.row i (s.row i + c • s.row j) with hu + by_cases hri : r = i + · subst hri + have e1 : s.row r = u r - c • u j := by + rw [hu, Function.update_self, Function.update_of_ne (Ne.symm hij)]; abel + rw [e1] + exact Submodule.sub_mem _ (Submodule.subset_span ⟨r, rfl⟩) + (Submodule.smul_mem _ _ (Submodule.subset_span ⟨j, rfl⟩)) + · have : s.row r = u r := by + rw [hu, Function.update_of_ne hri] + rw [this]; exact Submodule.subset_span ⟨r, rfl⟩ + | cross i => + have hiB : i ∈ B := by + by_contra h; exact hop ((hI.ab_iff i).mpr (Or.inl h)) + have hicr : i ∉ s.cr := fun h => hop ((hI.ab_iff i).mpr (Or.inr h)) + have hmono : span K ((fun μ => L (s.rho μ)) '' (s.cr : Set Reg)) ≤ + span K ((fun μ => L (Function.update s.rho i (s.row i) μ)) '' ((insert i s.cr : Finset Reg) : Set Reg)) := by + apply Submodule.span_mono + rintro _ ⟨μ, hμ, rfl⟩ + have hμi : μ ≠ i := fun e => hicr (e ▸ hμ) + refine ⟨μ, by simp [hμ], ?_⟩ + simp [Function.update_of_ne hμi] + refine ⟨?_, ?_, ?_, hI.top⟩ + · simp only [lstep]; exact Finset.insert_subset hiB hI.crB + · intro r; simp only [lstep, mem_insert] + rw [hI.ab_iff r]; tauto + · intro r hr + simp only [lstep, mem_insert] at hr ⊢ + rcases hr with rfl | hr + · apply Submodule.subset_span + exact ⟨r, by simp, by simp⟩ + · exact hmono (hI.up r hr) + +lemma linv_run {W : Type*} [AddCommGroup W] [Module K W] (B : Finset Reg) + (L : (Reg → K) →ₗ[K] W) : ∀ (s : LSt K Reg) (ops : List (LOp K Reg)), + LInv B L s → LLegal s ops → LInv B L (lrun s ops) + | s, [], hI, _ => hI + | s, .add i j c :: ops, hI, ⟨h, hL⟩ => linv_run B L _ ops (linv_step B L s _ hI h) hL + | s, .cross i :: ops, hI, ⟨h, hL⟩ => linv_run B L _ ops (linv_step B L s _ hI h) hL + +/-- restriction to the coordinates of registers born at dim `≤ k`. -/ +def resB (B : Finset Reg) : (Reg → K) →ₗ[K] (B → K) := LinearMap.funLeft K K (Subtype.val) + +lemma resB_single (B : Finset Reg) (r : Reg) (hr : r ∉ B) : resB B (Pi.single r (1 : K)) = 0 := by + funext b + have : (b : Reg) ≠ r := fun e => hr (e ▸ b.2) + simp [resB, LinearMap.funLeft_apply, Pi.single_apply, this] + +/-- **T2 (crossing-basis lemma), from the op semantics.** Run legal level-`k` ops from time 0 +(`B` = registers born at dim `≤ k`). Class-N hypothesis: every stayer (born `≤ k`, never crosses) +ends as its own token. Restrict rows to the coordinates of `B` (`resB`). Then +* `cr ⊆ B`; +* (complementarity) the crossing rows and the stayer tokens span complementary subspaces of `B → K`; +* (T2(a)) the crossing rows are linearly independent; +* (T2(b), existence) every register above level `k` at the end (born above, or crossed) has its + restricted final row in the span of the crossing rows. -/ +theorem T2_run (B : Finset Reg) (ops : List (LOp K Reg)) (hL : LLegal (lstart B) ops) + (hst : ∀ r ∈ B, r ∉ (lrun (lstart B) ops).cr → (lrun (lstart B) ops).row r = Pi.single r 1) : + (lrun (lstart (K := K) B) ops).cr ⊆ B ∧ + IsCompl (span K ((fun μ => resB B ((lrun (lstart B) ops).rho μ)) '' ((lrun (lstart B) ops).cr : Set Reg))) + (span K ((fun b => resB B (Pi.single b (1 : K))) '' ((B \ (lrun (lstart B) ops).cr : Finset Reg) : Set Reg))) ∧ + LinearIndependent K (fun μ : (lrun (lstart (K := K) B) ops).cr => resB B ((lrun (lstart B) ops).rho μ)) ∧ + (∀ r, r ∉ B ∨ r ∈ (lrun (lstart (K := K) B) ops).cr → + resB B ((lrun (lstart B) ops).row r) ∈ + span K ((fun μ => resB B ((lrun (lstart B) ops).rho μ)) '' ((lrun (lstart B) ops).cr : Set Reg))) := by + classical + set s := lrun (lstart (K := K) B) ops + have hI : LInv B (resB B) s := linv_run B (resB B) _ ops (linv_start B _ (resB_single B)) hL + set a := span K ((fun μ => resB B (s.rho μ)) '' (s.cr : Set Reg)) + set b := span K ((fun b => resB B (Pi.single b (1 : K))) '' ((B \ s.cr : Finset Reg) : Set Reg)) + have hsup : a ⊔ b = ⊤ := by + have hsurj : Function.Surjective (resB (K := K) B) := + LinearMap.funLeft_surjective_of_injective _ _ _ Subtype.val_injective + rw [eq_top_iff, ← LinearMap.range_eq_top.mpr hsurj, LinearMap.range_eq_map, ← hI.top, + Submodule.map_span, Submodule.span_le] + rintro _ ⟨_, ⟨r, rfl⟩, rfl⟩ + by_cases hr : r ∈ s.ab + · exact Submodule.mem_sup_left (hI.up r hr) + · have hrB : r ∈ B := by by_contra h; exact hr ((hI.ab_iff r).mpr (Or.inl h)) + have hrc : r ∉ s.cr := fun h => hr ((hI.ab_iff r).mpr (Or.inr h)) + apply Submodule.mem_sup_right + rw [hst r hrB hrc] + exact Submodule.subset_span ⟨r, by simp [hrB, hrc], rfl⟩ + have ha : finrank K a ≤ s.cr.card := finrank_span_image_le _ _ + have hb : finrank K b ≤ (B \ s.cr).card := finrank_span_image_le _ _ + have hV : finrank K (B → K) = s.cr.card + (B \ s.cr).card := by + rw [Module.finrank_fintype_fun_eq_card, Fintype.card_coe, add_comm, + Finset.card_sdiff_add_card_eq_card hI.crB] + obtain ⟨hc, hfa, -⟩ := compl_of_sup a b _ _ hsup ha hb hV + refine ⟨hI.crB, hc, ?_, fun r hr => hI.up r ((hI.ab_iff r).mpr hr)⟩ + rw [linearIndependent_iff_card_eq_finrank_span, Set.finrank] + have : Set.range (fun μ : s.cr => resB B (s.rho μ)) = (fun μ => resB B (s.rho μ)) '' (s.cr : Set Reg) := by + ext v; simp + rw [this, Fintype.card_coe]; exact hfa.symm + +end T2 + +/-! ### T3 with T2 discharged -/ + +section T3T2 + +open Module Submodule + +/-- **T3 with the complementarity discharged.** `slot_lemma` with its T2 hypotheses (independence of +the crossing rows, and the projection `P`) replaced by the T2 data: the crossing rows `ρ(Cr)` and the +stayer tokens `tok(St)` span `V`, `dim V = |Cr| + |St|`, and every 0-born non-crosser is a stayer. +(`T2_run` derives exactly this from the op semantics, with `V = B → K`.) -/ +theorem slot_lemma_T2 {K V Reg D C : Type*} [Field K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] [DecidableEq Reg] [Fintype D] + (Cr B0 W St : Finset Reg) (hW : W ⊆ B0 ∩ Cr) (ρ tok : Reg → V) + (hsup : span K (ρ '' (Cr : Set Reg)) ⊔ span K (tok '' (St : Set Reg)) = ⊤) + (hdim : finrank K V = Cr.card + St.card) + (hSt : ∀ b ∈ B0, b ∉ Cr → b ∈ St) + (hWS0 : ∀ μ ∈ W, ρ μ ∈ span K (tok '' (B0 : Set Reg))) + (land : Reg → C) (G : D → C) (hG : Function.Injective G) + (y x e : D → V) (A : D → Reg → K) + (hT2b : ∀ p, y p = ∑ μ ∈ Cr, A p μ • ρ μ) + (hsupp : ∀ p, ∀ μ ∈ Cr, μ ∉ W → A p μ ≠ 0 → land μ = G p) + (hy : ∀ p, y p = x p + e p) (he : ∀ p, e p ∈ span K (tok '' (B0 : Set Reg))) + (X : Submodule K V) (hx : ∀ p, x p ∈ X) (hXS : X ⊓ span K (tok '' (B0 : Set Reg)) = ⊥) + (hx0 : ∀ p, x p ≠ 0) : + Fintype.card D ≤ finrank K (span K (Set.range x)) + ((B0 ∩ Cr) \ W).card := by + obtain ⟨hc, hfa, -⟩ := compl_of_sup _ _ _ _ hsup (finrank_span_image_le _ _) + (finrank_span_image_le _ _) hdim + obtain ⟨P, hP1, hP2⟩ := proj_exists _ _ hc + have hli : LinearIndependent K (fun μ : Cr => ρ μ) := by + rw [linearIndependent_iff_card_eq_finrank_span, Set.finrank] + have : Set.range (fun μ : Cr => ρ μ) = ρ '' (Cr : Set Reg) := by ext v; simp + rw [this, Fintype.card_coe]; exact hfa.symm + refine slot_lemma Cr B0 W hW ρ tok P ?_ (fun μ hμ => hP1 _ (subset_span ⟨μ, hμ, rfl⟩)) + (fun b hb hbC => hP2 _ (subset_span ⟨b, hSt b hb hbC, rfl⟩)) hWS0 land G hG y x e A hT2b hsupp + hy he X hx hXS hx0 + intro g hg μ hμ + have := Fintype.linearIndependent_iff.mp hli (fun μ => g μ) + (by rw [Finset.sum_coe_sort Cr (fun μ => g μ • ρ μ)]; exact hg) + exact this ⟨μ, hμ⟩ + +/-- **T3 from the op semantics.** Level-7 run (`T2_run`): `B` = registers born at dim `≤ 7`, `B0 ⊆ B` +the 0-born ones, stayers end as their own tokens (class N). In `V = B → K` with crossing rows +`resB(ρ_μ)` and tokens `resB(e_b)`, the slot bound holds with only T2(b)'s coefficient/support data, +the W/S0 facts and the X/S0 split left as hypotheses. -/ +theorem slot_lemma_run {K Reg D C : Type*} [Field K] [Fintype Reg] [DecidableEq Reg] [Fintype D] + (B B0 W : Finset Reg) (hB0 : B0 ⊆ B) (ops : List (LOp K Reg)) (hL : LLegal (lstart B) ops) + (hst : ∀ r ∈ B, r ∉ (lrun (lstart B) ops).cr → (lrun (lstart B) ops).row r = Pi.single r 1) + (hW : W ⊆ B0 ∩ (lrun (lstart (K := K) B) ops).cr) + (hWS0 : ∀ μ ∈ W, resB B ((lrun (lstart B) ops).rho μ) ∈ + span K ((fun b => resB B (Pi.single b (1 : K))) '' (B0 : Set Reg))) + (land : Reg → C) (G : D → C) (hG : Function.Injective G) + (y x e : D → (B → K)) (A : D → Reg → K) + (hT2b : ∀ p, y p = ∑ μ ∈ (lrun (lstart (K := K) B) ops).cr, + A p μ • resB B ((lrun (lstart B) ops).rho μ)) + (hsupp : ∀ p, ∀ μ ∈ (lrun (lstart (K := K) B) ops).cr, μ ∉ W → A p μ ≠ 0 → land μ = G p) + (hy : ∀ p, y p = x p + e p) + (he : ∀ p, e p ∈ span K ((fun b => resB B (Pi.single b (1 : K))) '' (B0 : Set Reg))) + (X : Submodule K (B → K)) (hx : ∀ p, x p ∈ X) + (hXS : X ⊓ span K ((fun b => resB B (Pi.single b (1 : K))) '' (B0 : Set Reg)) = ⊥) + (hx0 : ∀ p, x p ≠ 0) : + Fintype.card D ≤ finrank K (span K (Set.range x)) + + ((B0 ∩ (lrun (lstart (K := K) B) ops).cr) \ W).card := by + obtain ⟨hcrB, hc, -, -⟩ := T2_run B ops hL hst + set s := lrun (lstart (K := K) B) ops + refine slot_lemma_T2 s.cr B0 W (B \ s.cr) hW (fun μ => resB B (s.rho μ)) + (fun b => resB B (Pi.single b (1 : K))) hc.sup_eq_top ?_ ?_ hWS0 land G hG y x e A hT2b hsupp + hy he X hx hXS hx0 + · rw [Module.finrank_fintype_fun_eq_card, Fintype.card_coe, add_comm, + Finset.card_sdiff_add_card_eq_card hcrB] + · intro b hb hbC; exact Finset.mem_sdiff.mpr ⟨hB0 hb, hbC⟩ + +end T3T2 + + +/-! ## T4. Departer law, corrected scope (all arrivals, owned included) -/ + +section T4 + +open Module Submodule + +variable {K Reg : Type*} [Field K] [Fintype Reg] [DecidableEq Reg] + +/-- events at ONE chart `c`, in time order: a register arrives with a row, a register is born at +`c` (row = its own token), an ADD `row_i += k·row_j`, or a register departs (moves up). -/ +inductive Ev (K Reg : Type*) + | arrive (i : Reg) (v : Reg → K) + | born (b : Reg) + | add (i j : Reg) (k : K) + | depart (i : Reg) + +/-- rows (initial-row coordinates `Reg → K`) and the set of registers present at `c`. -/ +structure St (K Reg : Type*) where + row : Reg → Reg → K + pres : Finset Reg + +def step : St K Reg → Ev K Reg → St K Reg + | s, .arrive i v => ⟨Function.update s.row i v, insert i s.pres⟩ + | s, .born b => ⟨Function.update s.row b (Pi.single b 1), insert b s.pres⟩ + | s, .add i j k => ⟨Function.update s.row i (s.row i + k • s.row j), s.pres⟩ + | s, .depart i => ⟨s.row, s.pres.erase i⟩ + +def run : St K Reg → List (Ev K Reg) → St K Reg + | s, [] => s + | s, ev :: evs => run (step s ev) evs + +/-- an ADD at `c` only reads and writes registers present at `c` (owned ones included: they are +registers like any other and must ARRIVE or be BORN at `c` to be present). -/ +def Legal : St K Reg → List (Ev K Reg) → Prop + | _, [] => True + | s, .add i j k :: evs => (i ∈ s.pres ∧ j ∈ s.pres) ∧ Legal (step s (.add i j k)) evs + | s, ev :: evs => Legal (step s ev) evs + +/-- invariant: every present row lies in `N` as long as all arrival rows and born tokens do. -/ +lemma run_inv (N : Submodule K (Reg → K)) : + ∀ (s : St K Reg) (evs : List (Ev K Reg)), Legal s evs → + (∀ i ∈ s.pres, s.row i ∈ N) → + (∀ i v, Ev.arrive i v ∈ evs → v ∈ N) → (∀ b, Ev.born b ∈ evs → Pi.single b 1 ∈ N) → + ∀ i ∈ (run s evs).pres, (run s evs).row i ∈ N + | s, [], _, hs, _, _ => hs + | s, ev :: evs, hL, hs, harr, hborn => by + have harr' : ∀ i v, Ev.arrive i v ∈ evs → v ∈ N := fun i v h => harr i v (by simp [h]) + have hborn' : ∀ b, Ev.born b ∈ evs → Pi.single b 1 ∈ N := fun b h => hborn b (by simp [h]) + cases ev with + | arrive i v => + refine run_inv N _ evs hL ?_ harr' hborn' + intro r hr + simp only [step, mem_insert] at hr ⊢ + by_cases hri : r = i + · subst hri; simp only [Function.update_self]; exact harr r v (by simp) + · rw [Function.update_of_ne hri]; exact hs r (hr.resolve_left hri) + | born b => + refine run_inv N _ evs hL ?_ harr' hborn' + intro r hr + simp only [step, mem_insert] at hr ⊢ + by_cases hrb : r = b + · subst hrb; simp only [Function.update_self]; exact hborn r (by simp) + · rw [Function.update_of_ne hrb]; exact hs r (hr.resolve_left hrb) + | add i j k => + obtain ⟨⟨hi, hj⟩, hL⟩ := hL + refine run_inv N _ evs hL ?_ harr' hborn' + intro r hr + simp only [step] at hr ⊢ + by_cases hri : r = i + · subst hri; simp only [Function.update_self] + exact N.add_mem (hs r hi) (N.smul_mem k (hs j hj)) + · rw [Function.update_of_ne hri]; exact hs r hr + | depart i => + refine run_inv N _ evs hL ?_ harr' hborn' + intro r hr + simp only [step, mem_erase] at hr ⊢ + exact hs r hr.2 + +/-- the c-born coordinates can be stripped: if `v ∈ span S ⊔ span tok(Born)`, every generator in +`S` vanishes on `Born`, and `v` vanishes on `Born`, then `v ∈ span S`. -/ +lemma strip_born (S : Set (Reg → K)) (Born : Finset Reg) (hS : ∀ u ∈ S, ∀ b ∈ Born, u b = 0) + (v : Reg → K) (hv : v ∈ span K S ⊔ span K ((fun b => Pi.single b (1 : K)) '' (Born : Set Reg))) + (hvB : ∀ b ∈ Born, v b = 0) : v ∈ span K S := by + let L : (Reg → K) →ₗ[K] (Reg → K) := + LinearMap.pi fun r => if r ∈ Born then LinearMap.proj r else 0 + have hL : ∀ u r, L u r = if r ∈ Born then u r else 0 := by + intro u r; by_cases hr : r ∈ Born <;> simp [L, hr] + have hA : span K S ≤ LinearMap.ker L := by + rw [Submodule.span_le]; intro u hu + simp only [SetLike.mem_coe, LinearMap.mem_ker]; funext r + rw [hL]; split_ifs with hr + · exact hS u hu r hr + · rfl + have hT : span K ((fun b => Pi.single b (1 : K)) '' (Born : Set Reg)) ≤ LinearMap.eqLocus L LinearMap.id := by + rw [Submodule.span_le]; rintro _ ⟨b, hb, rfl⟩ + simp only [SetLike.mem_coe, LinearMap.mem_eqLocus, LinearMap.id_coe, id_eq]; funext r + rw [hL]; split_ifs with hr + · rfl + · have : r ≠ b := fun h => hr (h ▸ hb) + simp [Pi.single_apply, this] + obtain ⟨a, ha, t, ht, rfl⟩ := Submodule.mem_sup.mp hv + have hLv : L (a + t) = 0 := by + funext r; rw [hL]; split_ifs with hr + · exact hvB r hr + · rfl + have hLa : L a = 0 := hA ha + have hLt : L t = t := LinearMap.mem_eqLocus.mp (hT ht) + rw [map_add, hLa, zero_add, hLt] at hLv + rw [hLv, add_zero]; exact ha + +/-- **T4 (departer law), corrected scope.** One chart `c ≠ V` with its event list `evs` (legal, from +the empty state). Arrivals `Arr = Pub ∪ Own` (public and OWNED registers arriving at `c`, disjoint), +arrival rows `arrRow`, which carry no `c`-born coordinates; `Born` = registers born at `c`, disjoint +from `Arr`. Class N: a public register still at `c` at the end (an ender), other than a Y main in +`Ey`, has final row = its own token, and `π` kills that token. Then +`dim π(Arr_c) ≤ #public departers + #owned arrivals + #Y enders`. -/ +theorem T4_departer (π : (Reg → K) →ₗ[K] (Reg → K)) (evs : List (Ev K Reg)) + (Pub Own Born Ey : Finset Reg) (arrRow : Reg → Reg → K) + (hL : Legal ⟨fun _ => 0, ∅⟩ evs) + (harr : ∀ i v, Ev.arrive i v ∈ evs → (i ∈ Pub ∪ Own) ∧ v = arrRow i) + (hborn : ∀ b, Ev.born b ∈ evs → b ∈ Born) + (hPO : Disjoint Pub Own) (hAB : Disjoint (Pub ∪ Own) Born) + (hrowB : ∀ i ∈ Pub ∪ Own, ∀ b ∈ Born, arrRow i b = 0) + (hfinal : ∀ h ∈ Pub, h ∈ (run ⟨fun _ => 0, ∅⟩ evs).pres → h ∉ Ey → + (run ⟨fun _ => 0, ∅⟩ evs).row h = Pi.single h 1) + (hπ : ∀ h ∈ Pub, h ∉ Ey → π (Pi.single h 1) = 0) : + finrank K ((span K (arrRow '' ((Pub ∪ Own : Finset Reg) : Set Reg))).map π) ≤ + (Pub.filter fun h => h ∉ (run ⟨fun _ => 0, ∅⟩ evs).pres).card + Own.card + Ey.card := by + classical + set sf := run ⟨fun _ => 0, ∅⟩ evs + set Arr := Pub ∪ Own + set A := span K (arrRow '' (Arr : Set Reg)) + set Etok := (Pub.filter fun h => h ∈ sf.pres) \ Ey + -- enders' tokens lie in A + have hEA : ∀ h ∈ Etok, (Pi.single h (1 : K) : Reg → K) ∈ A := by + intro h hh + simp only [Etok, mem_sdiff, mem_filter] at hh + have hM := run_inv (A ⊔ span K ((fun b => Pi.single b (1 : K)) '' (Born : Set Reg))) + ⟨fun _ => 0, ∅⟩ evs hL (by simp) + (fun i v hv => by + obtain ⟨hi, rfl⟩ := harr i v hv + exact Submodule.mem_sup_left (Submodule.subset_span ⟨i, hi, rfl⟩)) + (fun b hb => Submodule.mem_sup_right (Submodule.subset_span ⟨b, hborn b hb, rfl⟩)) + h hh.1.2 + rw [hfinal h hh.1.1 hh.1.2 hh.2] at hM + refine strip_born _ Born ?_ _ hM ?_ + · rintro _ ⟨i, hi, rfl⟩ b hb; exact hrowB i hi b hb + · intro b hb + have : h ≠ b := fun e => Finset.disjoint_left.mp hAB (mem_union_left _ hh.1.1) (e ▸ hb) + simp [Pi.single_apply, Ne.symm this] + -- rank–nullity on π restricted to A + let f := π.domRestrict A + have hrn := LinearMap.finrank_range_add_finrank_ker f + have hrange : LinearMap.range f = A.map π := LinearMap.range_domRestrict A π + -- Etok tokens are independent inside ker f + have hker : Etok.card ≤ finrank K (LinearMap.ker f) := by + let g : Etok → LinearMap.ker f := fun h => + ⟨⟨Pi.single h.1 1, hEA h.1 h.2⟩, by + have hh := h.2 + simp only [Etok, mem_sdiff, mem_filter] at hh + simp [f, hπ h.1 hh.1.1 hh.2]⟩ + have hli : LinearIndependent K g := by + apply LinearIndependent.of_comp ((LinearMap.ker f).subtype) + apply LinearIndependent.of_comp A.subtype + have e : (⇑A.subtype ∘ ⇑(LinearMap.ker f).subtype ∘ g) = fun h : Etok => Pi.single h.1 (1 : K) := by + funext h; rfl + rw [e] + have hb := (Pi.basisFun K Reg).linearIndependent + have : (fun h : Etok => Pi.single h.1 (1 : K)) = (Pi.basisFun K Reg) ∘ Subtype.val := by + funext h; simp + rw [this]; exact hb.comp _ Subtype.val_injective + simpa using hli.fintype_card_le_finrank + have hAc : finrank K A ≤ Arr.card := by + have : (arrRow '' (Arr : Set Reg)) = ((Arr.image arrRow : Finset (Reg → K)) : Set (Reg → K)) := by + simp + rw [show A = span K (arrRow '' (Arr : Set Reg)) from rfl, this] + exact (finrank_span_finset_le_card _).trans Finset.card_image_le + have hArr : Arr.card = Pub.card + Own.card := Finset.card_union_of_disjoint hPO + have hPub : Pub.card = (Pub.filter fun h => h ∉ sf.pres).card + (Pub.filter fun h => h ∈ sf.pres).card := by + rw [add_comm]; exact (Finset.card_filter_add_card_filter_not _).symm + have hEt : (Pub.filter fun h => h ∈ sf.pres).card ≤ Etok.card + Ey.card := by + calc _ ≤ (Etok ∪ Ey).card := by + apply card_le_card; intro h hh + by_cases hy : h ∈ Ey + · exact mem_union_right _ hy + · exact mem_union_left _ (mem_sdiff.mpr ⟨hh, hy⟩) + _ ≤ _ := card_union_le _ _ + rw [← hrange] + have : finrank K A = finrank K (LinearMap.range f) + finrank K (LinearMap.ker f) := hrn.symm + omega + +/-- T4 for the public arrival span: it sits inside the all-arrivals span, so the same right-hand +side (with the owned-arrival term) bounds it. Without `Own.card` it is false (`T4_public_only_false`). -/ +theorem T4_public (π : (Reg → K) →ₗ[K] (Reg → K)) (Pub Own : Finset Reg) (arrRow : Reg → Reg → K) : + finrank K ((span K (arrRow '' (Pub : Set Reg))).map π) ≤ + finrank K ((span K (arrRow '' ((Pub ∪ Own : Finset Reg) : Set Reg))).map π) := + Submodule.finrank_mono (Submodule.map_mono (Submodule.span_mono + (Set.image_mono (by simp)))) + +/-- each departer's move into `c` is not its final move, so it costs `h_e(a, dim c)` with +`dim c + 1 ≤ e`, which is `≥ κ = f(2)` (`kappa_le`). Re-export for T4. -/ +theorem T4_stop_cost (e a b : ℝ) (hab : 1 ≤ b - a) (hbe : 1 ≤ e - b) : fL 2 ≤ h fL e a b := + kappa_le e a b hab hbe + +/-- the public-arrivals-only version of T4 is FALSE in this model (GAPMAP scope finding: owned +register 1502 ADDs X content into Y main 213 at charts 593–595, 597). Registers `0` = public `h`, +`1` = owned `o`, `2` = X coordinate. `h` arrives with `e_h + e_x`, `o` arrives with `-e_x`, then +`h += o`: `h` ends at `c` as its own token (class N) and π kills it, yet the public arrival span has +`dim π = 1 > 0 = #public departers + #Y enders`. Counting the owned arrival (`T4_departer`) fixes it. -/ +theorem T4_public_only_false : + let π : (Fin 3 → ℚ) →ₗ[ℚ] (Fin 3 → ℚ) := (LinearMap.single ℚ (fun _ => ℚ) 2) ∘ₗ LinearMap.proj 2 + let evs : List (Ev ℚ (Fin 3)) := + [.arrive 0 (Pi.single 0 1 + Pi.single 2 1), .arrive 1 (-Pi.single 2 1), .add 0 1 1] + let sf := run (⟨fun _ => 0, ∅⟩ : St ℚ (Fin 3)) evs + Legal (⟨fun _ => 0, ∅⟩ : St ℚ (Fin 3)) evs ∧ (0 : Fin 3) ∈ sf.pres ∧ + sf.row 0 = Pi.single 0 1 ∧ π (Pi.single 0 1) = 0 ∧ + ¬ finrank ℚ ((span ℚ {(Pi.single 0 1 + Pi.single 2 1 : Fin 3 → ℚ)}).map π) ≤ 0 := by + intro π evs sf + refine ⟨?_, ?_, ?_, ?_, ?_⟩ + · simp [evs, Legal, step] + · simp [sf, evs, run, step] + · simp only [sf, evs, run, step] + funext r; fin_cases r <;> simp [Function.update, Pi.single_apply] + · simp [π] + · intro h0 + have hbot := Submodule.finrank_eq_zero.mp (Nat.le_zero.mp h0) + have hmem : π (Pi.single 0 1 + Pi.single 2 1) ∈ + (span ℚ {(Pi.single 0 1 + Pi.single 2 1 : Fin 3 → ℚ)}).map π := + Submodule.mem_map_of_mem (Submodule.mem_span_singleton_self _) + rw [hbot, Submodule.mem_bot] at hmem + have := congrFun hmem 2 + simp [π] at this + +end T4 + +end JunkLB2 + +#print axioms JunkLB2.hsum_tele +#print axioms JunkLB2.kappa_le +#print axioms JunkLB2.g9_nonneg +#print axioms JunkLB2.T1_Y +#print axioms JunkLB2.l_nonneg +#print axioms JunkLB2.T1_Y_le +#print axioms JunkLB2.Net.T1_bound +#print axioms JunkLB2.slot_lemma +#print axioms JunkLB2.proj_exists +#print axioms JunkLB2.run_inv +#print axioms JunkLB2.strip_born +#print axioms JunkLB2.Net.movesOf_chain +#print axioms JunkLB2.Net.chain_hsum +#print axioms JunkLB2.Net.reg_le_V +#print axioms JunkLB2.Net.reg_le_Y +#print axioms JunkLB2.Net.T1_cost +#print axioms JunkLB2.Net.T1_full +#print axioms JunkLB2.compl_of_sup +#print axioms JunkLB2.T2_run +#print axioms JunkLB2.slot_lemma_T2 +#print axioms JunkLB2.slot_lemma_run +#print axioms JunkLB2.T4_departer +#print axioms JunkLB2.T4_public +#print axioms JunkLB2.T4_stop_cost +#print axioms JunkLB2.T4_public_only_false diff --git a/research/p104-tiered-ceiling/lean/Nov15/JunkLB2.md b/research/p104-tiered-ceiling/lean/Nov15/JunkLB2.md new file mode 100644 index 0000000000..38163ae6b5 --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/JunkLB2.md @@ -0,0 +1,60 @@ +# JunkLB2.lean: JunkLB2 T1 (linked), T2, T3, T4 (Lean 4 + Mathlib), no sorry, ~9 s, 2.6 GB RSS +Source: internal notes (T1, T3, T4), with the T4 scope fix from internal notes §2. +Self-contained, namespace JunkLB2. h / gaps / hsum / two_point / Net / chain_append are copied from JunkM.lean. Axioms (all 25 printed): [propext, Classical.choice, Quot.sound]. + +**T1 (g9 pricing, class M).** +- `hsum_tele`: Σ h_e over any chain = f(e−d0) − f(e−last) − Σ f(gaps). The chain need not end at e. +- `T1_Y`: for Y_p with 0 < d1 < … < 8, the real cost Σ h_8(0::d1::…) equals the g9 charge on every move but the first, plus l(d1) = f(8) − f(d1) − f(9−d1). Needs f(0) = f(1) = 0. +- `l_nonneg` (1 ≤ d ≤ 8, by convexity), `l_one`, `T1_Y_le`: charged ≤ real. Direct Y (d1 = 8) is covered and gives 0. Registers ending at V: the charge is the real cost by definition. +- `g9_nonneg`: g9 ≥ 0 for a ≤ b ≤ 9. +- `Net.T1_bound`: Σ_{junk pairs} dist_c(A_q → G_p) ≤ cost. Hypotheses: + - a chain of moves A_q → G_p for each pair (JunkM `hpath_of_junk` now supplies it); + - chart 0 holds no X port; + - every move not leaving chart 0 is charged ≥ c (= g9); + - Σ_m w_m ≤ cost. +- Σ_m w_m ≤ public cost is now a THEOREM , `Net.T1_cost`; `Net.T1_full` chains it with `T1_bound`. + - Op semantics = JunkM's (`path_to_chain`): charts never decrease; `mv t i` is register i's move chart_t(i) → chart_{t+1}(i) when its chart rises. New hypothesis: the moves are EXACTLY these (each move is `mv t i` for one rising step t < n: `hsurj`, `hinj`). + - `movesOf i n` = register i's moves in time order; `movesOf_chain`: they form a chain birth chart → chart at time n. + - `chain_hsum`: Σ h_e over the chain's moves = hsum_e over its dim list (dim : C → ℕ, strictly monotone). + - Charge `wz`: 0 on moves out of chart z (dim 0), else c(s,t) = max(g9,0) (= g9 on every real move, `cg_eq`). + - Model M as hypotheses: Y mains (Ym) are born at z and end at dim 8; every other register ends at dim 9. Public cost := Σ_i hsum_{8 or 9}(i's dim chain) (I1). + - Per register: `reg_le_V` (charge ≤ Σ g9 = cost; 0-born non-Y first moves are charged 0 ≤ g9) and `reg_le_Y` (first move free, rest g9, then `T1_Y_le`). + - Still hypotheses in T1_full: the pair chains (`hpath`, from JunkM `hpath_of_junk`), and chart z holds no X port. + +**T3 (slot lemma), `slot_lemma`.** Conclusion: |D| ≤ rank{x_p : p ∈ D} + |(B0 ∩ Cr) \ W|. Hypotheses, all explicit: +- T2(a): the crossing rows ρ(Cr) are independent. +- T2(b): y_p = Σ A_{pμ} ρ_μ. A non-W crosser has A ≠ 0 only if it lands at G_p, and G is injective. +- W ⊆ B0 ∩ Cr. Crossing rows of W lie in S0 = span tok(B0). +- y_p = x_p + e_p with e_p ∈ S0, 0 ≠ x_p ∈ X, and X ⊓ S0 = 0. +- A linear P that fixes ρ(Cr) and kills the tokens of 0-born non-crossers. `proj_exists` builds P from IsCompl (the complementarity the T2 proof asserts). + +Two findings from the formal proof: +1. The prose step "dim(S0/W) ≤ |Z| after removing stayers" needs this projection. The proof runs in P(S0), and rank{P x_p} ≤ rank{x_p}. +2. Directness of the Y_p in D is never used. D may be any set of Y mains with x_p ≠ 0. Non-direct ones are simply in Z themselves. + +**T2 (crossing-basis lemma), now PROVED from op semantics , `T2_run`.** +- Model at level k: ops are ADD i += c·j (i ≠ j, both on the same side of level k, i.e. co-present) and `cross i` (i's first move from dim ≤ k to > k; its row then is ρ_i). Moves that do not cross k change nothing at this level and are omitted. Time 0: every row is its own token; B = registers born at dim ≤ k. +- Hypothesis (class N): every stayer (in B, never crosses) ends as its own token. +- Conclusions, in V = B → K (rows restricted to B's coordinates, `resB`): + - cr ⊆ B; + - complementarity: span ρ(Cr) and span tok(B \ Cr) are complementary (`IsCompl`); + - T2(a): the crossing rows are linearly independent; + - T2(b), existence: every register above k at the end has its restricted final row in span ρ(Cr). +- Proof (formal): invariants (`LInv`) = above-k rows stay in the span of crossing rows so far; all rows span everything (ADD with i ≠ j is invertible). Then `compl_of_sup`: a ⊔ b = ⊤ with dim a ≤ |Cr|, dim b ≤ |St|, dim V = |Cr| + |St| forces IsCompl and dim a = |Cr|. Stayer-token independence is not needed as input. +- Discharged in T3: `slot_lemma_T2` replaces slot_lemma's independence + projection hypotheses by "ρ(Cr) ∪ tok(St) spans V, dim V = |Cr| + |St|, 0-born non-crossers are stayers". `slot_lemma_run` instantiates it on the run (V = B → K, B0 ⊆ B). +- Still hypotheses in slot_lemma_run: T2(b)'s coefficients A and their support (A_{pμ} ≠ 0 ⇒ μ lands at G_p for non-W μ; the path/landing argument), W's rows in S0, e_p ∈ S0, X ⊓ S0 = 0, x_p ≠ 0. The expansion's existence is proved (T2_run part 4), and with independence A is unique. + +**T4 (departer law), CHOSEN SCOPE: owned arrivals counted.** +- Model: one chart's event list (arrive / born / ADD / depart), with ADDs only between registers present at c. Owned registers are registers too, so to be present at c they must arrive or be born there. +- `run_inv`: every present row lies in span(arrival rows) + span(c-born tokens). This is the prose's first step, and it holds only when ALL arrivals are counted. +- `strip_born`: a row with no c-born coordinates lies in the arrival span. This needs arrival rows to carry no c-born coordinates (a hypothesis). +- `T4_departer`: dim π(Arr_c^all) ≤ #public departers + #owned arrivals + #Y enders. Class-N hypothesis: public enders other than Y end as their own token, and π kills it. +- `T4_public`: the public-arrival span obeys the same bound. +- `T4_stop_cost` / `kappa_le`: a non-final move costs h_e(a,b) ≥ f(2) when b − a ≥ 1 and e − b ≥ 1. +- **Statement found false:** `T4_public_only_false`. The prose T4 (Arr_c = public arrivals, a ≤ d (+1)) fails in the same model, mirroring the gap map's owned-1502 → Y-213 charts. A public h arrives with e_h + e_x and owned o arrives with −e_x. Then h += o, so h ends as its own token. Yet dim π(public span) = 1 > 0. The gap is exactly step one of the prose proof. With no owned arrivals, `T4_departer` gives the prose statement back. + +Still prose / hypotheses: +- "arrivals carry no c-born coordinates" (content only flows upward); +- class-N final rows; +- one arrival per register at c. +- T5 path bound: charging half formalized in Nov15/JunkT5.lean . It is stated with the corrected T4 (owned arrivals) and needs root charts to be terminal. Descent is still prose. diff --git a/research/p104-tiered-ceiling/lean/Nov15/JunkLawA.lean b/research/p104-tiered-ceiling/lean/Nov15/JunkLawA.lean new file mode 100644 index 0000000000..b775992212 --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/JunkLawA.lean @@ -0,0 +1,365 @@ +import Mathlib.LinearAlgebra.Matrix.Rank +import Mathlib.Algebra.Order.BigOperators.Ring.Finset +import Mathlib.Data.Fintype.Perm +import Mathlib.Tactic + +/-! +JUNKLAW Law A: the index-coding / acyclic-subset bound with NO junk-count assumption. See JunkLawA.md. + +Abstract model (`LawAModel`). Rows `t : Fin P` are the owned lifetimes (P = 104 on the natives); `M t` is the X-part `alpha_t . arr_t` of the row `v_t`. + * `arr : Fin D → (Fin P → K)`: the arrival X-vectors, ONE PER OWNED DESCENDING MOVE. + * `hspan`: every `v_t` is a combination of arrivals (premise: SP + nested owned moves, JL1 s.1). + * `hdiag`: `M t t ≠ 0` (premise: the Y_t odd part is `c_t e_t`, `c_t ≠ 0`). + * `Ev`, `hodd`: off-diagonal entries live only on `Ev`-related (even) partners (premise: odd part of `Y_t` is `c_t e_t`). + * `hpart`: each `t` has at most 48 even partners (premise: the 48-law universe; used only for the bound `j t ≤ 48`). +`j t` = number of off-diagonal nonzeros of row `t` (the junk of the arrival row). `J := Σ_t j t` is `|J^arr|`. + +Results: `lawA` (`Σ_t 1/(j_t+1) ≤ rank M ≤ D`), `lawA_cs` (`P² ≤ D (J + P)`, i.e. `J ≥ P²/D - P`), `lawA_lin` (`J ≥ 2 (P - D)`), `lawA_96` +(`P = 104`, `D ≤ 56 ⇒ 96 ≤ J`), `junkSet_card` (the junk cells as a `Finset (ℕ × ℕ)` have cardinality `J`), `single_arrival_clique` (core of Theorem S). +-/ +namespace JunkLawA +open Finset +open scoped Classical + +variable {K : Type*} [Field K] {P : ℕ} + +/-- the junk partners of row `t`: off-diagonal nonzeros -/ +noncomputable def outN (M : Matrix (Fin P) (Fin P) K) (t : Fin P) : Finset (Fin P) := + univ.filter fun s => s ≠ t ∧ M t s ≠ 0 + +/-- junk count `j_t` of row `t` -/ +noncomputable def jc (M : Matrix (Fin P) (Fin P) K) (t : Fin P) : ℕ := (outN M t).card + +/-! ### 1. counting permutations (Caro-Wei / MAIS expectation) -/ + +/-- the permutations ranking `x` strictly below every other element of `B` -/ +noncomputable def firstSet (B : Finset (Fin P)) (x : Fin P) : Finset (Equiv.Perm (Fin P)) := + univ.filter fun σ => ∀ c ∈ B, c ≠ x → σ x < σ c + +theorem firstSet_swap (B : Finset (Fin P)) (x y : Fin P) (hy : y ∈ B) (σ : Equiv.Perm (Fin P)) (hσ : σ ∈ firstSet B x) : + σ * Equiv.swap x y ∈ firstSet B y := by + simp only [firstSet, mem_filter, mem_univ, true_and] at hσ ⊢ + intro c hc hcy + simp only [Equiv.Perm.coe_mul, Function.comp_apply, Equiv.swap_apply_right] + by_cases hcx : c = x + · subst hcx + have hxy : c ≠ y := hcy + rw [Equiv.swap_apply_left] + have := hσ y hy (Ne.symm hxy) + exact this + · rw [Equiv.swap_apply_of_ne_of_ne hcx hcy] + exact hσ c hc hcx + +theorem card_firstSet_eq (B : Finset (Fin P)) (x y : Fin P) (hx : x ∈ B) (hy : y ∈ B) : + (firstSet B y).card = (firstSet B x).card := by + symm + refine Finset.card_nbij' (fun σ => σ * Equiv.swap x y) (fun σ => σ * Equiv.swap x y) ?_ ?_ ?_ ?_ + · intro σ hσ; exact firstSet_swap B x y hy σ hσ + · intro σ hσ + have := firstSet_swap B y x hx σ hσ + rwa [Equiv.swap_comm] at this + · intro σ _; simp [mul_assoc] + · intro σ _; simp [mul_assoc] + +theorem sum_card_firstSet (B : Finset (Fin P)) : + ∑ b ∈ B, (firstSet B b).card = if B.Nonempty then P.factorial else 0 := by + split_ifs with hB + · have e : ∀ b, (firstSet B b).card = ∑ σ : Equiv.Perm (Fin P), if σ ∈ firstSet B b then 1 else 0 := by + intro b; rw [Finset.sum_boole]; simp + have e' : ∀ σ : Equiv.Perm (Fin P), (B.filter fun b => σ ∈ firstSet B b).card = ∑ b ∈ B, if σ ∈ firstSet B b then 1 else 0 := by + intro σ; rw [Finset.sum_boole]; simp + have h1 : ∑ b ∈ B, (firstSet B b).card = ∑ σ : Equiv.Perm (Fin P), (B.filter fun b => σ ∈ firstSet B b).card := by + calc ∑ b ∈ B, (firstSet B b).card = ∑ b ∈ B, ∑ σ : Equiv.Perm (Fin P), if σ ∈ firstSet B b then 1 else 0 := + Finset.sum_congr rfl (fun b _ => e b) + _ = ∑ σ : Equiv.Perm (Fin P), ∑ b ∈ B, if σ ∈ firstSet B b then 1 else 0 := Finset.sum_comm + _ = _ := Finset.sum_congr rfl (fun σ _ => (e' σ).symm) + have h2 : ∀ σ : Equiv.Perm (Fin P), (B.filter fun b => σ ∈ firstSet B b).card = 1 := by + intro σ + obtain ⟨b0, hb0, hmin⟩ := Finset.exists_min_image B σ hB + rw [Finset.card_eq_one] + refine ⟨b0, ?_⟩ + ext b + simp only [mem_filter, firstSet, mem_univ, true_and, mem_singleton] + constructor + · rintro ⟨hb, hall⟩ + by_contra hne + have h1 := hall b0 hb0 (Ne.symm hne) + have h2 := hmin b hb + exact absurd h1 (not_lt.mpr h2) + · rintro rfl + refine ⟨hb0, fun c hc hcb => ?_⟩ + exact lt_of_le_of_ne (hmin c hc) (fun h => hcb (σ.injective h).symm) + rw [h1] + simp [h2, Fintype.card_perm] + · rw [Finset.not_nonempty_iff_eq_empty.mp hB]; simp + +/-- the key count: `(|B|) * #{σ | x first in B} = P!` -/ +theorem card_mul_firstSet (B : Finset (Fin P)) (x : Fin P) (hx : x ∈ B) : + B.card * (firstSet B x).card = P.factorial := by + have h := sum_card_firstSet B + rw [if_pos ⟨x, hx⟩] at h + rw [← h, Finset.card_eq_sum_ones, Finset.sum_mul] + exact Finset.sum_congr rfl fun b hb => by rw [one_mul, card_firstSet_eq B x b hx hb] + +/-- the MAIS set of a ranking: rows ranked before all of their junk partners -/ +noncomputable def mais (M : Matrix (Fin P) (Fin P) K) (σ : Equiv.Perm (Fin P)) : Finset (Fin P) := + univ.filter fun t => ∀ s ∈ outN M t, σ t < σ s + +theorem mem_firstSet_insert (M : Matrix (Fin P) (Fin P) K) (t : Fin P) (σ : Equiv.Perm (Fin P)) : + σ ∈ firstSet (insert t (outN M t)) t ↔ t ∈ mais M σ := by + simp only [firstSet, mais, mem_filter, mem_univ, true_and, mem_insert] + constructor + · intro h s hs + exact h s (Or.inr hs) (by simp only [outN, mem_filter] at hs; exact hs.2.1) + · intro h c hc hct + rcases hc with rfl | hc + · exact absurd rfl hct + · exact h c hc + +theorem t_not_mem_outN (M : Matrix (Fin P) (Fin P) K) (t : Fin P) : t ∉ outN M t := by simp [outN] + +/-- average count: `Σ_σ |mais σ| = P! Σ_t 1/(j_t+1)` -/ +theorem sum_mais (M : Matrix (Fin P) (Fin P) K) : + (∑ σ : Equiv.Perm (Fin P), ((mais M σ).card : ℝ)) = (P.factorial : ℝ) * ∑ t, (1 : ℝ) / (jc M t + 1) := by + have h1 : (∑ σ : Equiv.Perm (Fin P), ((mais M σ).card : ℝ)) = ∑ t, ((firstSet (insert t (outN M t)) t).card : ℝ) := by + simp only [Finset.card_eq_sum_ones, Nat.cast_sum, Nat.cast_one, mais] + simp only [Finset.sum_filter] + rw [Finset.sum_comm] + refine Finset.sum_congr rfl fun t _ => ?_ + simp only [firstSet, Finset.sum_filter] + refine Finset.sum_congr rfl fun σ _ => ?_ + have := mem_firstSet_insert M t σ + simp only [firstSet, mais, mem_filter, mem_univ, true_and] at this + by_cases h : ∀ s ∈ outN M t, σ t < σ s + · rw [if_pos h, if_pos (this.mpr h)] + · rw [if_neg h, if_neg (fun h' => h (this.mp h'))] + rw [h1, Finset.mul_sum] + refine Finset.sum_congr rfl fun t _ => ?_ + have hc := card_mul_firstSet (insert t (outN M t)) t (mem_insert_self _ _) + rw [Finset.card_insert_of_notMem (t_not_mem_outN M t)] at hc + have hc' : ((jc M t : ℝ) + 1) * ((firstSet (insert t (outN M t)) t).card : ℝ) = P.factorial := by + have := congrArg (fun n : ℕ => (n : ℝ)) hc + simpa [jc] using this + have hpos : (0 : ℝ) < (jc M t : ℝ) + 1 := by positivity + field_simp + linarith + +/-! ### 2. triangular rows are independent -/ + +theorem mais_linIndep (M : Matrix (Fin P) (Fin P) K) (hdiag : ∀ t, M t t ≠ 0) (σ : Equiv.Perm (Fin P)) : + LinearIndependent K (fun t : mais M σ => M.row (t : Fin P)) := by + rw [Fintype.linearIndependent_iff] + intro g hg + by_contra hne + push Not at hne + obtain ⟨i1, hi1⟩ := hne + have hne' : (univ.filter fun i : mais M σ => g i ≠ 0).Nonempty := ⟨i1, by simpa using hi1⟩ + obtain ⟨i0, hi0, hmin⟩ := Finset.exists_min_image _ (fun i : mais M σ => σ (i : Fin P)) hne' + have hg0 : g i0 ≠ 0 := by simpa using hi0 + have hcoord := congrFun hg (i0 : Fin P) + simp only [Finset.sum_apply, Pi.smul_apply, smul_eq_mul, Pi.zero_apply] at hcoord + have hterm : ∀ i : mais M σ, i ≠ i0 → g i * M.row (i : Fin P) (i0 : Fin P) = 0 := by + intro i hi + by_cases hgi : g i = 0 + · simp [hgi] + · have hle := hmin i (by simpa using hgi) + have hne2 : (i : Fin P) ≠ (i0 : Fin P) := fun h => hi (Subtype.ext h) + have hlt : σ (i0 : Fin P) < σ (i : Fin P) := lt_of_le_of_ne hle (fun h => hne2 (σ.injective h).symm) + have hzero : M (i : Fin P) (i0 : Fin P) = 0 := by + by_contra hM + have hmem : (i0 : Fin P) ∈ outN M (i : Fin P) := by simp [outN, mem_filter, Ne.symm hne2, hM] + have := (Finset.mem_filter.mp i.2).2 _ hmem + exact absurd hlt (not_lt.mpr this.le) + simp [Matrix.row, hzero] + rw [Finset.sum_eq_single i0 (fun i _ hi => hterm i hi) (by simp)] at hcoord + exact mul_ne_zero hg0 (hdiag _) hcoord + +/-- `|mais σ| ≤ rank M` for every ranking -/ +theorem mais_card_le_rank (M : Matrix (Fin P) (Fin P) K) (hdiag : ∀ t, M t t ≠ 0) (σ : Equiv.Perm (Fin P)) : + (mais M σ).card ≤ M.rank := by + have hli := mais_linIndep M hdiag σ + have h1 : Module.finrank K (Submodule.span K (Set.range fun t : mais M σ => M.row (t : Fin P))) = Fintype.card (mais M σ) := + finrank_span_eq_card hli + have h2 : Submodule.span K (Set.range fun t : mais M σ => M.row (t : Fin P)) ≤ Submodule.span K (Set.range M.row) := + Submodule.span_mono (by rintro _ ⟨t, rfl⟩; exact ⟨t, rfl⟩) + rw [Matrix.rank_eq_finrank_span_row] + have := Submodule.finrank_mono h2 + rw [h1] at this + simpa using this + +/-- **MAIS bound**: `Σ_t 1/(j_t+1) ≤ rank M` (diagonal nonzero; `j_t` = off-diagonal nonzeros of row t). -/ +theorem maisBound (M : Matrix (Fin P) (Fin P) K) (hdiag : ∀ t, M t t ≠ 0) : + ∑ t, (1 : ℝ) / (jc M t + 1) ≤ M.rank := by + rcases Nat.eq_zero_or_pos P with h0 | hP + · subst h0; simp + have hfac : (0 : ℝ) < P.factorial := by exact_mod_cast Nat.factorial_pos P + have hsum := sum_mais M + by_contra hlt + push Not at hlt + have hall : ∀ σ ∈ (univ : Finset (Equiv.Perm (Fin P))), ((mais M σ).card : ℝ) ≤ M.rank := fun σ _ => by + exact_mod_cast mais_card_le_rank M hdiag σ + have := Finset.sum_le_sum hall + rw [hsum, Finset.sum_const, Finset.card_univ, Fintype.card_perm, Fintype.card_fin, nsmul_eq_mul] at this + nlinarith + +/-! ### 3. the abstract model and Law A -/ + +/-- Law A model: P rows, D arrival vectors; every premise is a field. -/ +structure LawAModel (K : Type*) [Field K] (P D : ℕ) where + M : Matrix (Fin P) (Fin P) K + arr : Fin D → (Fin P → K) + /-- every row `v_t` is a combination of arrivals: one arrival vector per owned descending move -/ + hspan : ∀ t, M t ∈ Submodule.span K (Set.range arr) + /-- Y_t odd spec: the diagonal coefficient `c_t ≠ 0` -/ + hdiag : ∀ t, M t t ≠ 0 + /-- `Ev t s`: `s` is an even partner of `t` -/ + Ev : Fin P → Fin P → Prop + /-- odd off-diagonals vanish -/ + hodd : ∀ t s, s ≠ t → M t s ≠ 0 → Ev t s + /-- 48 even partners -/ + hpart : ∀ t, (univ.filter fun s => s ≠ t ∧ Ev t s).card ≤ 48 + +namespace LawAModel +variable {D : ℕ} (m : LawAModel K P D) + +noncomputable def j (t : Fin P) : ℕ := jc m.M t +/-- the arrival junk `|J^arr|` -/ +noncomputable def J : ℕ := ∑ t, m.j t + +theorem rank_le : m.M.rank ≤ D := by + classical + rw [Matrix.rank_eq_finrank_span_row] + have h : Submodule.span K (Set.range m.M.row) ≤ Submodule.span K (Set.range m.arr) := + Submodule.span_le.mpr (by rintro _ ⟨t, rfl⟩; exact m.hspan t) + refine le_trans (Submodule.finrank_mono h) ?_ + have h' := finrank_range_le_card (R := K) m.arr + rw [Fintype.card_fin] at h' + exact h' + +/-- `j t ≤ 48` -/ +theorem j_le (t : Fin P) : m.j t ≤ 48 := by + show (outN m.M t).card ≤ 48 + refine le_trans (Finset.card_le_card ?_) (m.hpart t) + intro s hs + simp only [outN, mem_filter, mem_univ, true_and] at hs ⊢ + exact ⟨hs.1, m.hodd t s hs.1 hs.2⟩ + +/-- **Law A**: `Σ_t 1/(j_t+1) ≤ rank M ≤ D`. -/ +theorem lawA : ∑ t, (1 : ℝ) / (m.j t + 1) ≤ D := by + have h1 := maisBound m.M m.hdiag + have h2 : (m.M.rank : ℝ) ≤ D := by exact_mod_cast m.rank_le + exact le_trans h1 h2 + +/-- Cauchy-Schwarz form: `P² ≤ D (J + P)`, i.e. `J ≥ P²/D - P`. -/ +theorem lawA_cs : (P : ℝ) ^ 2 ≤ D * (m.J + P) := by + have h := Finset.sq_sum_div_le_sum_sq_div (s := (univ : Finset (Fin P))) (fun _ => (1 : ℝ)) (g := fun t => (m.j t : ℝ) + 1) + (fun t _ => by positivity) + simp only [Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul, mul_one, one_pow] at h + have hA := m.lawA + have hs : ∑ t, ((m.j t : ℝ) + 1) = m.J + P := by + simp [J, Finset.sum_add_distrib] + rw [hs] at h + have hpos : (0 : ℝ) < m.J + P ∨ P = 0 := by + rcases Nat.eq_zero_or_pos P with h0 | h0 + · exact Or.inr h0 + · left; have : (0 : ℝ) < P := by exact_mod_cast h0 + have : (0 : ℝ) ≤ m.J := by positivity + linarith + rcases hpos with hp | h0 + · rw [div_le_iff₀ hp] at h + have h2 : (P : ℝ) ^ 2 ≤ (∑ t, (1 : ℝ) / (m.j t + 1)) * (m.J + P) := by + simpa using h + exact le_trans h2 (mul_le_mul_of_nonneg_right hA hp.le) + · subst h0 + have : (0 : ℝ) ≤ D * m.J := by positivity + simpa using this + +/-- integer tangent: `1 - j/2 ≤ 1/(j+1)` -/ +theorem tangent (j : ℕ) : 1 - (j : ℝ) / 2 ≤ 1 / ((j : ℝ) + 1) := by + rcases Nat.lt_or_ge j 2 with h | h + · interval_cases j <;> norm_num + · have hj : (2 : ℝ) ≤ j := by exact_mod_cast h + have : (0 : ℝ) < 1 / ((j : ℝ) + 1) := by positivity + linarith + +/-- linear form: `J ≥ 2 (P - D)` (reals) -/ +theorem lawA_lin : 2 * ((P : ℝ) - D) ≤ m.J := by + have h := m.lawA + have h2 : ∑ t, (1 - (m.j t : ℝ) / 2) ≤ ∑ t, (1 : ℝ) / (m.j t + 1) := Finset.sum_le_sum fun t _ => tangent _ + have h3 : ∑ t, (1 - (m.j t : ℝ) / 2) = P - (m.J : ℝ) / 2 := by + simp [J, Finset.sum_sub_distrib, ← Finset.sum_div, Nat.cast_sum] + linarith + +/-- **the number used by the ceiling**: 104 rows and at most 56 descending moves force `96 ≤ J`. -/ +theorem lawA_96 (m : LawAModel K 104 D) (hD : D ≤ 56) : 96 ≤ m.J := by + have h := m.lawA_lin + have hD' : (D : ℝ) ≤ 56 := by exact_mod_cast hD + have : (96 : ℝ) ≤ m.J := by push_cast at h; linarith + exact_mod_cast this + +end LawAModel + +/-! ### 4. the junk cells as a `Finset (ℕ × ℕ)` -/ + +/-- junk cells `(t, s)`, `s ≠ t`, `M t s ≠ 0`, as natural-number pairs -/ +noncomputable def junkSet (M : Matrix (Fin P) (Fin P) K) : Finset (ℕ × ℕ) := + (univ.filter fun p : Fin P × Fin P => p.1 ≠ p.2 ∧ M p.1 p.2 ≠ 0).image fun p => ((p.1 : ℕ), (p.2 : ℕ)) + +theorem junkSet_card (M : Matrix (Fin P) (Fin P) K) : (junkSet M).card = ∑ t, jc M t := by + unfold junkSet + rw [Finset.card_image_of_injective _ (by + intro p q h + simp only [Prod.mk.injEq] at h + exact Prod.ext (Fin.ext h.1) (Fin.ext h.2))] + rw [Finset.card_filter, Fintype.sum_prod_type] + refine Finset.sum_congr rfl fun t _ => ?_ + rw [jc, outN, Finset.card_filter] + refine Finset.sum_congr rfl fun s _ => ?_ + by_cases h : s ≠ t ∧ M t s ≠ 0 + · rw [if_pos h, if_pos ⟨Ne.symm h.1, h.2⟩] + · rw [if_neg h, if_neg (fun h' => h ⟨Ne.symm h'.1, h'.2⟩)] + +theorem LawAModel.junkSet_card {D : ℕ} (m : LawAModel K P D) : (junkSet m.M).card = m.J := JunkLawA.junkSet_card m.M + +/-- Law A in cardinality form for the ceiling: `D ≤ 56` descending moves over 104 rows force `96 ≤ |junkSet|`. -/ +theorem junkSet_card_ge_96 {D : ℕ} (m : LawAModel K 104 D) (hD : D ≤ 56) : 96 ≤ (junkSet m.M).card := by + rw [m.junkSet_card]; exact m.lawA_96 hD + +/-! ### 5. Theorem S, core (clique form) -/ + +/-- Rows served by ONE arrival vector `a` (`M t = c t • a`) are pairwise junk partners (so pairwise even). -/ +theorem single_arrival_clique (M : Matrix (Fin P) (Fin P) K) (hdiag : ∀ t, M t t ≠ 0) (a : Fin P → K) (c : Fin P → K) + (G : Finset (Fin P)) (hrow : ∀ t ∈ G, M t = c t • a) : + ∀ t ∈ G, ∀ s ∈ G, t ≠ s → M t s ≠ 0 := by + intro t ht s hs hts + have hct : c t ≠ 0 := by + intro h; have := hdiag t; rw [hrow t ht] at this; simp [h] at this + have has : a s ≠ 0 := by + intro h; have := hdiag s; rw [hrow s hs] at this; simp [h] at this + rw [hrow t ht] + simpa using mul_ne_zero hct has + +/-- hence `j_t ≥ |G| - 1` for each served row, and the group carries `≥ |G| (|G| - 1)` junk cells. -/ +theorem single_arrival_junk (M : Matrix (Fin P) (Fin P) K) (hdiag : ∀ t, M t t ≠ 0) (a : Fin P → K) (c : Fin P → K) + (G : Finset (Fin P)) (hrow : ∀ t ∈ G, M t = c t • a) : + G.card * (G.card - 1) ≤ ∑ t ∈ G, jc M t := by + have h : ∀ t ∈ G, G.card - 1 ≤ jc M t := by + intro t ht + rw [← Finset.card_erase_of_mem ht] + refine Finset.card_le_card fun s hs => ?_ + simp only [mem_erase] at hs + simp only [outN, mem_filter, mem_univ, true_and] + exact ⟨hs.1, single_arrival_clique M hdiag a c G hrow t ht s hs.2 (Ne.symm hs.1)⟩ + calc G.card * (G.card - 1) = ∑ _t ∈ G, (G.card - 1) := by simp + _ ≤ ∑ t ∈ G, jc M t := Finset.sum_le_sum h + +end JunkLawA + +#print axioms JunkLawA.maisBound +#print axioms JunkLawA.LawAModel.lawA +#print axioms JunkLawA.LawAModel.lawA_cs +#print axioms JunkLawA.LawAModel.lawA_lin +#print axioms JunkLawA.LawAModel.lawA_96 +#print axioms JunkLawA.junkSet_card_ge_96 +#print axioms JunkLawA.single_arrival_clique +#print axioms JunkLawA.single_arrival_junk diff --git a/research/p104-tiered-ceiling/lean/Nov15/JunkLawA.md b/research/p104-tiered-ceiling/lean/Nov15/JunkLawA.md new file mode 100644 index 0000000000..29222897c7 --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/JunkLawA.md @@ -0,0 +1,38 @@ +# JunkLawA.lean + JunkLawACeiling.lean + CongestionNativeN/Z*.lean: Law A with no junk-count assumption, and the ceiling without hJ +Kernel only: no sorry, no native_decide; `#print axioms` of every theorem = [propext, Classical.choice, Quot.sound]. Builds (runlean.sh, one at a time, peak <= 3.3 GB): JunkLawA 7 s, CongestionNativeNDefs 10 s, NSig0-4 ~7 s each, NPt 25 s, NUnit 5 s, CongestionNativeN 9 s, JunkLawACeiling 5 s; Z-versions the same. (CongestionNativeJ.olean was built first; it had no olean.) +No paper step was found false as written. Two scope facts the paper text blurs are stated below (s.4). + +## 1. Law A (JunkLawA.lean) [PROVED, abstract model] +`LawAModel K P D`: `M : Matrix (Fin P) (Fin P) K` (row t = X-part of v_t = alpha_t.arr_t), `arr : Fin D -> (Fin P -> K)` (ONE arrival vector per owned descending move), and premises as fields: +- `hspan` : every row M t lies in span(arr) [premise: SP (public moves ascend, ADD/COPY same chart, owned INIT empty) + nested owned moves; paper JL1 s.1, NOT derived in Lean] +- `hdiag` : M t t != 0 [premise: Y_t odd part = c_t e_t, c_t != 0] +- `Ev`, `hodd` : M t s != 0, s != t => Ev t s [premise: odd off-diagonals vanish] +- `hpart` : each t has <= 48 Ev-partners [48-law universe; used only for `j_le : j t <= 48`] +`jc M t` = #off-diagonal nonzeros of row t; `J = sum_t j t`. +- `maisBound`: sum_t 1/(j_t+1) <= rank M, for ANY matrix with nonzero diagonal. Proof in Lean: Caro-Wei over all P! rankings (`card_mul_firstSet`: |B| * #{sigma : x first in B} = P!, by the swap bijection `card_firstSet_eq`; `sum_mais`: sum_sigma |MAIS_sigma| = P! sum 1/(j+1)), then rows of a sigma-triangular set are linearly independent (`mais_linIndep`) so |MAIS_sigma| <= rank. +- `LawAModel.rank_le`: rank M <= D. `lawA`: **sum_t 1/(j_t+1) <= D**. +- `lawA_cs`: P^2 <= D (J + P), i.e. J >= P^2/D - P. `tangent`: 1 - j/2 <= 1/(j+1) for every natural j (equality at j = 0, 1; FALSE for real j in (0,1), so the integrality of j_t is used). `lawA_lin`: **J >= 2 (P - D)**. `lawA_96`: P = 104, D <= 56 => **96 <= J** (this is J_A(56) of JL1; the linear form is sharper than P^2/D - P at D = 56: 89.1 vs 96). +- `junkSet M : Finset (N x N)` = the junk cells; `junkSet_card = J`; `junkSet_card_ge_96 : D <= 56 -> 96 <= |junkSet|`. +- Theorem S core (`single_arrival_clique`, `single_arrival_junk`): rows served by ONE arrival vector (M t = c_t a) are pairwise junk partners, so a group G carries >= |G|(|G|-1) junk cells and j_t >= |G|-1. Only this clique form is formalised; "#single <= M" and the route Gram cut (rank G[P_x,N_x] <= m_x, JC1 s.2b-c) are register-machine statements, NOT in Lean. + +## 2. The ceiling without hJ +- `CongestionNativeN.lean`: **ceiling_native_N96** = `ceiling_native_J` with `hJ : 96 <= J.card`, domain [tN0, 1], tN0 = 1510270/10^8 = **.0151027**. Pieces tN = .0151027|.0151077|.0153077|.0253077|.07|.1 (4 point-form pieces on s >= .93 with F_base monotone, 1 box-form piece on s in [.9,.93], then t >= .1 by `own56_floor` as in ceiling_native). Kernel: 5 sigma certificates, 4 F_base point enclosures (min margin 5.0e-3 in 17L units), 2 box enclosures, 5 unit lower bounds, dLo>0 reused (`hFbJ_of`), table arithmetic by norm_num. +- `JunkLawACeiling.lean`: **ceiling_noHJ** : (m : LawAModel K 104 D) (hD : D <= 56) (hJdef : J = junkSet m.M) + all other hypotheses of ceiling_native_N96 => F(1-t, invoice (caller 6 7) n 17) < 0 on [tN0, 1], i.e. **kappa <= .0151027** (own56, m <= 5). +- `CongestionNativeZ.lean`: **ceiling_native_Z0**, no junk-count hypothesis at all (N = 0), tZ0 = **.0151869** (pieces .0151869|.0151889|.0152889|.0202889|.07|.1). No junk-count assumption and no UPPER bound on owned mass; it still assumes `hmass` (ks.sum >= 56), `hk`, `hmd`, `hmr`, `hY` and the rest of class K. +- Certified digits (7 d.p.): N = 96 true crossing ~.01510261 (float .0151026 FAILS as a 7-digit piece start: margin -1.9e-3; .0151027 passes, +1.2e-2). N = 0: .0151869 passes (+6.9e-3), .0151868 fails (-7.0e-3). jl1-4's float values (.0151026 / .0151869) are right to the digit; the certified 7-digit value for N = 96 is .0151027. +- Tables: generated by scripts not included in this package; Lean checks only the stated hypotheses over the certified rationals. + +## 3. Every hypothesis of ceiling_noHJ (status) +Proved/derived in Lean: hJ (from Law A: `junkSet_card_ge_96`), sigma certificates, F_base enclosures and monotonicity, all unit lower bounds, table arithmetic, own56_floor branch. +Premises of the abstract model (named fields, s.1): hspan, hdiag, hodd, hpart = paper-proved (JL1), natives: computed fact (jl2: off-diagonal odd 0, diagonals nonzero, 48 partners, rank 11 <= D 24); the register-machine facts behind hspan (SP premises, nested owned moves, one vector per move) are NOT formalised. +- hD : D <= 56. In Lean `D` is the number of arrival vectors in ANY spanning set of the rows, so `hD` is in effect rank M <= 56 (>= rank M; natives: rank 11, D = 24). It is implied by <= 56 owned descending moves, hence by descending mass <= 56 (class definition own56 + paper split lemma); natives: computed fact (24 descents, mass 56). +- hJdef : J = junkSet m.M: the identification of the set J of hcong/hdist with the arrival junk cells; Lean cannot check it, a naming link as in ceiling_native ("ONE J"): hcong, hdist and the junk count must hold for the SAME J, and Lean does not tie that J to the word. +- hmono, hd9, hmix, hk, hmass, hmd, hmr, hF, hY, hst, hEex: as CongestionNative.md items 1-7 (natives: computed fact; hEex proved only as identity on natives). +- hcong* (s in [.9, 1 - tN0]), hdist: paper-proved (Path-Cut/I3, HC1 sec. 2); Lean: hypotheses (register machine / shape DAG not formalised); natives: computed fact. +- hspMono, hcstMono (on [tN0, 1/10]): paper-proved (HC3), Lean: hypotheses. hspTabN (5 spF lower brackets), hcstTabN (5 cst upper brackets): computed fact, outward Decimal, Lean: hypotheses over certified rationals. (ceiling_native_Z0 keeps the same list; spF/unit entries are positive but multiplied by 0.) +- NOT needed: hJ, Rank8C56, PlaneSep. + +## 4. Scope (honest) +- Law A at D <= 56 is a statement about the own56 class (hD). The jl4 argument that "owned mass > 56 never pays" is NOT formalised; and I could not find where it enters the Lean chain: the owned surplus Omega cancels exactly in `branchC_om`, so the formal chain depends on the owned layer only through N. Consequence: for words with D > 56 the Lean results are ceiling_native_Z0 (kappa <= .0151869), and the improvement .0151869 -> .0151027 needs hD. For 56 < D < 104 the intermediate N = ceil(2(104-D)) ceilings were not built (they lie between the two). +- The N = 96 ceiling is for the class K with J^arr as Law A defines it (arrival rows with premises of s.1); words outside the Y_t odd spec are not covered. +- The rank-tight witnesses (clique blocks, JL3) show Law A cannot be improved by more than ~5-20% as a rank law; the 1936-4962 band stays the hJ conjecture (not touched). diff --git a/research/p104-tiered-ceiling/lean/Nov15/JunkLawACeiling.lean b/research/p104-tiered-ceiling/lean/Nov15/JunkLawACeiling.lean new file mode 100644 index 0000000000..f13d48f1fb --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/JunkLawACeiling.lean @@ -0,0 +1,46 @@ +import Nov15.JunkLawA +import Nov15.CongestionNativeN + +/-! +CEILING WITHOUT hJ: `ceiling_noHJ` = `ceiling_native_N96` with `hJ : 96 <= |J|` DERIVED from Law A. +The junk set `J` is tied to the abstract model: `hJdef : J = junkSet m.M` (the off-diagonal nonzeros of the arrival rows), `m : LawAModel K 104 D` carries the Law A +premises (spans of D arrival vectors, nonzero diagonal, odd off-diagonals zero, 48-partner universe) and `hD : D <= 56` is the own56 premise. Lean's `D` is the size of ANY spanning set of arrival vectors, so `hD` in effect says rank M <= 56 (the natives have rank 11, D = 24); it is implied by <= 56 owned descending moves, hence by descending mass <= 56. +The same `J` carries the junk count, `hcong` and `hdist`; `hJdef` is a naming link and Lean does not tie `J` to any word. +Conclusion: `F(1 - t, invoice (caller 6 7) n 17) < 0` for t in [tN0, 1], tN0 = .0151027, i.e. kappa <= .0151027. See JunkLawA.md. +-/ +namespace CongestionNative +open NumCertK JointCeiling CallerCost CongestionI3 CongestionI3Dual Finset + +/-- **the no-hJ ceiling.** -/ +theorem ceiling_noHJ {ι : Type*} [DecidableEq ι] {K : Type*} [Field K] {D : ℕ} + (m : JunkLawA.LawAModel K 104 D) (hD : D ≤ 56) + (R : Finset ι) (nR : ι → ℕ) (dR : ι → ℕ → ℕ) + (hmono : ∀ r ∈ R, ∀ i < nR r, dR r i ≤ dR r (i + 1)) (hd9 : ∀ r ∈ R, dR r (nR r) ≤ 9) + (hmix : (R.filter fun r => Mixed dR nR r).card ≤ 5) + (n : Inv) (ks : List ℕ) (mr st : ℕ) (E : ℝ → ℝ) (J : Finset (ℕ × ℕ)) (distF : ℝ → ℕ × ℕ → ℝ) (spF cstF : ℝ → ℝ) + (hk : ∀ k ∈ ks, 1 ≤ k ∧ k ≤ 9) (hmass : 56 ≤ ks.sum) (hmd : 8 ≤ ks.length) (hmr : 8 ≤ mr) + (hF : ∀ s, 0 ≤ s → s ≤ 1 → Finv s n ≤ -400 * (8 : ℝ) ^ s - dprice ks s - mr - E s) + (hY : 104 ≤ st + (ks.length + mr)) + (hst : ∀ s, 0 ≤ s → s ≤ 1 → (2 - (2 : ℝ) ^ s) * st ≤ E s) + (hEex : ∀ s, 0 ≤ s → s ≤ 1 → ∑ r ∈ R, ex (gs s) (lev dR r) (nR r) ≤ E s) + (hcong : ∀ s, 9 / 10 ≤ s → s ≤ 1 - ((tN0 : ℚ) : ℝ) → + ∑ p ∈ J, min (distF s p) (capC s) - corrC cstF s ≤ + ∑ r ∈ R, ∑ i ∈ range (nR r), c2 (gs s) (lev dR r i) (lev dR r (i + 1)) + Omega ks mr s) + (hdist : ∀ s, 9 / 10 ≤ s → s ≤ 1 - ((tN0 : ℚ) : ℝ) → ∀ p ∈ J, spF (1 - s) ≤ distF s p) + (hJdef : J = JunkLawA.junkSet m.M) + (hspMono : MonotoneOn spF (Set.Icc ((tN0 : ℚ) : ℝ) (1 / 10))) + (hcstMono : MonotoneOn cstF (Set.Icc ((tN0 : ℚ) : ℝ) (1 / 10))) + (hspTabN : ((spFloN0 : ℚ) : ℝ) ≤ spF ((tN0 : ℚ) : ℝ) ∧ ((spFloN1 : ℚ) : ℝ) ≤ spF ((tN1 : ℚ) : ℝ) ∧ + ((spFloN2 : ℚ) : ℝ) ≤ spF ((tN2 : ℚ) : ℝ) ∧ ((spFloN3 : ℚ) : ℝ) ≤ spF ((tN3 : ℚ) : ℝ) ∧ + ((spFloN4 : ℚ) : ℝ) ≤ spF ((tN4 : ℚ) : ℝ)) + (hcstTabN : cstF ((tN1 : ℚ) : ℝ) ≤ ((cHN0 : ℚ) : ℝ) ∧ cstF ((tN2 : ℚ) : ℝ) ≤ ((cHN1 : ℚ) : ℝ) ∧ + cstF ((tN3 : ℚ) : ℝ) ≤ ((cHN2 : ℚ) : ℝ) ∧ cstF ((tN4 : ℚ) : ℝ) ≤ ((cHN3 : ℚ) : ℝ) ∧ + cstF ((tN5 : ℚ) : ℝ) ≤ ((cHN4 : ℚ) : ℝ)) : + ∀ t : ℝ, ((tN0 : ℚ) : ℝ) ≤ t → t ≤ 1 → Finv (1 - t) (invoice (caller 6 7) n 17) < 0 := by + have hJ : 96 ≤ J.card := by rw [hJdef]; exact JunkLawA.junkSet_card_ge_96 m hD + exact ceiling_native_N96 R nR dR hmono hd9 hmix n ks mr st E J distF spF cstF hk hmass hmd hmr hF hY hst hEex hcong hdist hJ + hspMono hcstMono hspTabN hcstTabN + +end CongestionNative + +#print axioms CongestionNative.ceiling_noHJ diff --git a/research/p104-tiered-ceiling/lean/Nov15/NumCertK.lean b/research/p104-tiered-ceiling/lean/Nov15/NumCertK.lean new file mode 100644 index 0000000000..1398c28ed5 --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/NumCertK.lean @@ -0,0 +1,382 @@ +import Mathlib.Analysis.SpecialFunctions.Log.Deriv +import Mathlib.Analysis.SpecialFunctions.Pow.Deriv +import Mathlib.Analysis.Complex.ExponentialBounds +import Mathlib.Analysis.Calculus.Deriv.MeanValue + +/-! +NUMCERT-K . Kernel-checked interval arithmetic for the numeric crossing hypotheses of the kappa ceilings. +Section 1: rational enclosures of ln r (chain ln(c+2) = ln(c+1) + 2 atanh(1/(2c+3)) with an explicit geometric tail) and of exp (Taylor of x/8, explicit +remainder `Real.exp_bound'`, eighth power), packaged as `pow_lo`/`pow_hi`: r^s in [pLo r a, pHi r b] for s in [a,b]. Kernel only; no native_decide. +-/ + +namespace NumCertK +open Finset + +def SC : ℚ := 10 ^ 30 +def rdn (q : ℚ) : ℚ := ((⌊q * SC⌋ : ℤ) : ℚ) / SC +def rup (q : ℚ) : ℚ := ((⌈q * SC⌉ : ℤ) : ℚ) / SC +theorem SC_pos : (0 : ℚ) < SC := by unfold SC; positivity +theorem rdn_le (q : ℚ) : rdn q ≤ q := by + unfold rdn; rw [div_le_iff₀ SC_pos]; exact Int.floor_le _ +theorem le_rup (q : ℚ) : q ≤ rup q := by + unfold rup; rw [le_div_iff₀ SC_pos]; exact Int.le_ceil _ +theorem rdn_nonneg {q : ℚ} (h : 0 ≤ q) : 0 ≤ rdn q := by + unfold rdn + have : (0 : ℤ) ≤ ⌊q * SC⌋ := Int.floor_nonneg.mpr (mul_nonneg h SC_pos.le) + have h2 : (0 : ℚ) ≤ ((⌊q * SC⌋ : ℤ) : ℚ) := by exact_mod_cast this + exact div_nonneg h2 SC_pos.le +theorem rup_nonneg {q : ℚ} (h : 0 ≤ q) : 0 ≤ rup q := le_trans h (le_rup q) +theorem rdn_mono {p q : ℚ} (h : p ≤ q) : rdn p ≤ rdn q := by + unfold rdn + apply div_le_div_of_nonneg_right _ SC_pos.le + exact_mod_cast Int.floor_mono (mul_le_mul_of_nonneg_right h SC_pos.le) +theorem rup_mono {p q : ℚ} (h : p ≤ q) : rup p ≤ rup q := by + unfold rup + apply div_le_div_of_nonneg_right _ SC_pos.le + exact_mod_cast Int.ceil_mono (mul_le_mul_of_nonneg_right h SC_pos.le) + +/-! ### 1. ln -/ +def aS (a n : ℕ) : ℚ := + ∑ k ∈ range n, 2 * (1 / (2 * (k : ℚ) + 1)) * (1 / (2 * (a : ℚ) + 1)) ^ (2 * k + 1) +def aTail (a n : ℕ) : ℚ := + 2 * (1 / (2 * (a : ℚ) + 1)) ^ (2 * n + 1) / ((2 * (n : ℚ) + 1) * (1 - (1 / (2 * (a : ℚ) + 1)) ^ 2)) + +theorem atanh_bounds (a n : ℕ) (ha : 0 < a) : + ((aS a n : ℚ) : ℝ) ≤ Real.log (1 + (a : ℝ)⁻¹) ∧ + Real.log (1 + (a : ℝ)⁻¹) ≤ ((aS a n : ℚ) : ℝ) + ((aTail a n : ℚ) : ℝ) := by + have haR : (0 : ℝ) < a := by exact_mod_cast ha + have hs := Real.hasSum_log_one_add_inv haR + set y : ℝ := 1 / (2 * (a : ℝ) + 1) with hy + have hy0 : 0 < y := by rw [hy]; positivity + have hy1 : y < 1 := by + rw [hy, div_lt_one (by positivity)]; have : (1:ℝ) ≤ a := by exact_mod_cast ha + linarith + set f : ℕ → ℝ := fun k => 2 * (1 / (2 * (k : ℝ) + 1)) * y ^ (2 * k + 1) with hf + have hS : ((aS a n : ℚ) : ℝ) = ∑ k ∈ range n, f k := by + simp only [aS, hf, hy]; push_cast; rfl + have ht := (hasSum_nat_add_iff' n).mpr hs + rw [hS] + have hfpos : ∀ k, 0 ≤ f k := fun k => by simp only [hf]; positivity + constructor + · have := ht.nonneg (fun k => hfpos (k + n)) + linarith + · set c : ℝ := 2 * (1 / (2 * (n : ℝ) + 1)) * y ^ (2 * n + 1) with hc + have hy2 : y ^ 2 < 1 := by nlinarith + have hg : HasSum (fun k : ℕ => c * (y ^ 2) ^ k) (c * (1 - y ^ 2)⁻¹) := + (hasSum_geometric_of_lt_one (by positivity) hy2).mul_left c + have hle : ∀ k : ℕ, f (k + n) ≤ c * (y ^ 2) ^ k := by + intro k + simp only [hf, hc] + have e : y ^ (2 * (k + n) + 1) = y ^ (2 * n + 1) * (y ^ 2) ^ k := by + rw [← pow_mul]; rw [← pow_add]; congr 1; ring + push_cast + rw [e] + have h1 : 1 / (2 * ((k : ℝ) + n) + 1) ≤ 1 / (2 * (n : ℝ) + 1) := by + apply one_div_le_one_div_of_le (by positivity); nlinarith [(Nat.cast_nonneg k : (0:ℝ) ≤ k)] + have h2 : 0 ≤ y ^ (2 * n + 1) * (y ^ 2) ^ k := by positivity + nlinarith [mul_le_mul_of_nonneg_right h1 h2] + have := hasSum_le hle ht hg + have hT : ((aTail a n : ℚ) : ℝ) = c * (1 - y ^ 2)⁻¹ := by + simp only [aTail, hc, hy]; push_cast + have : (1 - (1 / (2 * (a : ℝ) + 1)) ^ 2) ≠ 0 := by + have := hy2; rw [hy] at this; intro h; linarith + field_simp + rw [hT]; linarith + +def N : ℕ := 36 +def lnLoC : ℕ → ℚ + | 0 => 0 + | c + 1 => lnLoC c + rdn (aS (c + 1) N) +def lnHiC : ℕ → ℚ + | 0 => 0 + | c + 1 => lnHiC c + rup (aS (c + 1) N + aTail (c + 1) N) +/-- bounds for ln r (r >= 1) -/ +def lnLo (r : ℕ) : ℚ := lnLoC (r - 1) +def lnHi (r : ℕ) : ℚ := lnHiC (r - 1) + +theorem aS_nonneg (a n : ℕ) : 0 ≤ aS a n := by + unfold aS; apply Finset.sum_nonneg; intro k _; positivity +theorem aTail_nonneg (a n : ℕ) : 0 ≤ aTail a n := by + unfold aTail + apply div_nonneg (by positivity) + apply mul_nonneg (by positivity) + by_cases h : a = 0 + · subst h; simp + · have : (1:ℚ) ≤ a := by exact_mod_cast Nat.pos_of_ne_zero h + have h1 : 1 / (2 * (a : ℚ) + 1) ≤ 1 := by rw [div_le_one (by positivity)]; linarith + have h0 : 0 ≤ 1 / (2 * (a : ℚ) + 1) := by positivity + nlinarith + +theorem ln_chain (c : ℕ) : + ((lnLoC c : ℚ) : ℝ) ≤ Real.log ((c : ℝ) + 1) ∧ Real.log ((c : ℝ) + 1) ≤ ((lnHiC c : ℚ) : ℝ) := by + induction c with + | zero => simp [lnLoC, lnHiC] + | succ c ih => + obtain ⟨h1, h2⟩ := ih + have hc : (0 : ℝ) < (c : ℝ) + 1 := by positivity + have e : Real.log (((c + 1 : ℕ) : ℝ) + 1) = Real.log ((c : ℝ) + 1) + Real.log (1 + (((c + 1 : ℕ) : ℝ))⁻¹) := by + rw [← Real.log_mul hc.ne' (by positivity)] + congr 1; push_cast; field_simp + obtain ⟨b1, b2⟩ := atanh_bounds (c + 1) N (Nat.succ_pos c) + rw [e] + constructor + · have : ((rdn (aS (c + 1) N) : ℚ) : ℝ) ≤ ((aS (c + 1) N : ℚ) : ℝ) := by exact_mod_cast rdn_le _ + simp only [lnLoC]; push_cast at *; linarith + · have : ((aS (c + 1) N + aTail (c + 1) N : ℚ) : ℝ) ≤ ((rup (aS (c + 1) N + aTail (c + 1) N) : ℚ) : ℝ) := + by exact_mod_cast le_rup _ + simp only [lnHiC]; push_cast at *; linarith + +theorem lnLo_le (r : ℕ) (hr : 1 ≤ r) : ((lnLo r : ℚ) : ℝ) ≤ Real.log r := by + have h := (ln_chain (r - 1)).1 + unfold lnLo + have : ((r - 1 : ℕ) : ℝ) + 1 = r := by rw [Nat.cast_sub hr]; simp + rwa [this] at h +theorem le_lnHi (r : ℕ) (hr : 1 ≤ r) : Real.log r ≤ ((lnHi r : ℚ) : ℝ) := by + have h := (ln_chain (r - 1)).2 + unfold lnHi + have : ((r - 1 : ℕ) : ℝ) + 1 = r := by rw [Nat.cast_sub hr]; simp + rwa [this] at h + +theorem lnLoC_nonneg (c : ℕ) : 0 ≤ lnLoC c := by + induction c with + | zero => simp [lnLoC] + | succ c ih => simp only [lnLoC]; exact add_nonneg ih (rdn_nonneg (aS_nonneg _ _)) +theorem lnHiC_mono : Monotone lnHiC := by + apply monotone_nat_of_le_succ; intro c + simp only [lnHiC] + have := rup_nonneg (add_nonneg (aS_nonneg (c + 1) N) (aTail_nonneg (c + 1) N)) + linarith +theorem lnLo_nonneg (r : ℕ) : 0 ≤ lnLo r := lnLoC_nonneg _ +theorem lnHi_nonneg (r : ℕ) : 0 ≤ lnHi r := by + have : (0:ℚ) ≤ lnHiC 0 := by simp [lnHiC] + exact le_trans this (lnHiC_mono (Nat.zero_le _)) + +theorem lnHi_145 : lnHi 145 ≤ 5 := by unfold lnHi; decide +kernel +theorem lnHi_le_5 (r : ℕ) (hr : r ≤ 145) : lnHi r ≤ 5 := by + refine le_trans ?_ lnHi_145 + exact lnHiC_mono (by omega) + +/-! ### 2. exp -/ +def NE : ℕ := 24 +def eS (y : ℚ) : ℚ := ∑ m ∈ range NE, y ^ m / (Nat.factorial m : ℚ) +def eR (y : ℚ) : ℚ := y ^ NE * ((NE : ℚ) + 1) / ((Nat.factorial NE : ℚ) * NE) +/-- lower / upper enclosure of exp x: (Taylor of x/8)^8 with outward fixed-point rounding -/ +def eLo (x : ℚ) : ℚ := rdn ((rdn (eS (x / 8))) ^ 8) +def eHi (x : ℚ) : ℚ := rup ((rup (eS (x / 8) + eR (x / 8))) ^ 8) + +theorem eLo_le (x : ℚ) (hx : 0 ≤ x) : ((eLo x : ℚ) : ℝ) ≤ Real.exp x := by + have hx0 : (0:ℝ) ≤ x := by exact_mod_cast hx + have hy : (0 : ℝ) ≤ (x : ℝ) / 8 := by positivity + have h1 := Real.sum_le_exp_of_nonneg hy NE + have hS : ((eS (x / 8) : ℚ) : ℝ) = ∑ m ∈ range NE, ((x : ℝ) / 8) ^ m / (Nat.factorial m : ℝ) := by + simp only [eS]; push_cast; rfl + have h0 : 0 ≤ eS (x / 8) := by + unfold eS; apply Finset.sum_nonneg; intro m _; have : 0 ≤ x / 8 := by positivity + positivity + have h2 : ((rdn (eS (x / 8)) : ℚ) : ℝ) ≤ Real.exp ((x : ℝ) / 8) := by + have : ((rdn (eS (x / 8)) : ℚ) : ℝ) ≤ ((eS (x / 8) : ℚ) : ℝ) := by exact_mod_cast rdn_le _ + linarith + have h3 : (0 : ℝ) ≤ ((rdn (eS (x / 8)) : ℚ) : ℝ) := by exact_mod_cast rdn_nonneg h0 + have h4 : (((rdn (eS (x / 8))) ^ 8 : ℚ) : ℝ) ≤ Real.exp x := by + push_cast + calc ((rdn (eS (x / 8)) : ℚ) : ℝ) ^ 8 ≤ (Real.exp ((x : ℝ) / 8)) ^ 8 := pow_le_pow_left₀ h3 h2 8 + _ = Real.exp x := by rw [← Real.exp_nat_mul]; congr 1; push_cast; ring + have h5 : ((rdn ((rdn (eS (x / 8))) ^ 8) : ℚ) : ℝ) ≤ (((rdn (eS (x / 8))) ^ 8 : ℚ) : ℝ) := by + exact_mod_cast rdn_le _ + unfold eLo; linarith + +theorem le_eHi (x : ℚ) (hx : 0 ≤ x) (hx8 : x ≤ 8) : Real.exp x ≤ ((eHi x : ℚ) : ℝ) := by + have hx0 : (0:ℝ) ≤ x := by exact_mod_cast hx + have hx8' : (x:ℝ) ≤ 8 := by exact_mod_cast hx8 + have hy : (0 : ℝ) ≤ (x : ℝ) / 8 := by positivity + have hy1 : (x : ℝ) / 8 ≤ 1 := by linarith + have h1 := Real.exp_bound' hy hy1 (n := NE) (by unfold NE; norm_num) + have hS : ((eS (x / 8) + eR (x / 8) : ℚ) : ℝ) = + (∑ m ∈ range NE, ((x : ℝ) / 8) ^ m / (Nat.factorial m : ℝ)) + + ((x : ℝ) / 8) ^ NE * ((NE : ℝ) + 1) / ((Nat.factorial NE : ℝ) * NE) := by + simp only [eS, eR]; push_cast; rfl + have h2 : Real.exp ((x : ℝ) / 8) ≤ ((rup (eS (x / 8) + eR (x / 8)) : ℚ) : ℝ) := by + have : ((eS (x / 8) + eR (x / 8) : ℚ) : ℝ) ≤ ((rup (eS (x / 8) + eR (x / 8)) : ℚ) : ℝ) := by + exact_mod_cast le_rup _ + linarith + have h3 : Real.exp x ≤ (((rup (eS (x / 8) + eR (x / 8))) ^ 8 : ℚ) : ℝ) := by + push_cast + calc Real.exp x = (Real.exp ((x : ℝ) / 8)) ^ 8 := by rw [← Real.exp_nat_mul]; congr 1; push_cast; ring + _ ≤ _ := pow_le_pow_left₀ (Real.exp_pos _).le h2 8 + have h5 : (((rup (eS (x / 8) + eR (x / 8))) ^ 8 : ℚ) : ℝ) ≤ ((rup ((rup (eS (x / 8) + eR (x / 8))) ^ 8) : ℚ) : ℝ) := by + exact_mod_cast le_rup _ + unfold eHi; linarith + +/-! ### 3. r^s on an interval of exponents -/ +def pLo (r : ℕ) (a : ℚ) : ℚ := eLo (rdn (a * lnLo r)) +def pHi (r : ℕ) (b : ℚ) : ℚ := eHi (rup (b * lnHi r)) + +/-- **rpow bound (lower)**: for 1 <= r, 0 <= a <= s: pLo r a <= r^s. -/ +theorem pow_lo (r : ℕ) (hr : 1 ≤ r) (a : ℚ) (ha : 0 ≤ a) (s : ℝ) (hs : (a : ℝ) ≤ s) : + ((pLo r a : ℚ) : ℝ) ≤ (r : ℝ) ^ s := by + have hr1 : (1 : ℝ) ≤ r := by exact_mod_cast hr + have hrp : (0 : ℝ) < r := by linarith + have ha0 : (0:ℝ) ≤ a := by exact_mod_cast ha + have h1 : (r : ℝ) ^ (a : ℝ) ≤ (r : ℝ) ^ s := Real.rpow_le_rpow_of_exponent_le hr1 hs + have hx0 : 0 ≤ rdn (a * lnLo r) := rdn_nonneg (mul_nonneg ha (lnLo_nonneg r)) + have h2 := eLo_le _ hx0 + have h3 : ((rdn (a * lnLo r) : ℚ) : ℝ) ≤ Real.log r * a := by + have a1 : ((rdn (a * lnLo r) : ℚ) : ℝ) ≤ ((a * lnLo r : ℚ) : ℝ) := by exact_mod_cast rdn_le _ + have a2 := lnLo_le r hr + push_cast at a1 + nlinarith + have e := Real.rpow_def_of_pos hrp (a : ℝ) + unfold pLo + have := Real.exp_le_exp.mpr h3 + linarith + +/-- **rpow bound (upper)**: for 1 <= r <= 145, 0 <= s <= b <= 1: r^s <= pHi r b. -/ +theorem pow_hi (r : ℕ) (hr : 1 ≤ r) (hr2 : r ≤ 145) (b : ℚ) (hb0 : 0 ≤ b) (hb1 : b ≤ 1) (s : ℝ) + (hs : s ≤ (b : ℝ)) : + (r : ℝ) ^ s ≤ ((pHi r b : ℚ) : ℝ) := by + have hr1 : (1 : ℝ) ≤ r := by exact_mod_cast hr + have hrp : (0 : ℝ) < r := by linarith + have h1 : (r : ℝ) ^ s ≤ (r : ℝ) ^ (b : ℝ) := Real.rpow_le_rpow_of_exponent_le hr1 hs + have hx0 : 0 ≤ rup (b * lnHi r) := rup_nonneg (mul_nonneg hb0 (lnHi_nonneg r)) + have h5 := lnHi_le_5 r hr2 + have hx8 : rup (b * lnHi r) ≤ 8 := by + have : b * lnHi r ≤ 5 := by nlinarith [lnHi_nonneg r] + have h6 := rup_mono this + have h7 : rup 5 = 5 := by unfold rup SC; norm_num + linarith + have h2 := le_eHi _ hx0 hx8 + have h3 : Real.log r * b ≤ ((rup (b * lnHi r) : ℚ) : ℝ) := by + have a1 : ((b * lnHi r : ℚ) : ℝ) ≤ ((rup (b * lnHi r) : ℚ) : ℝ) := by exact_mod_cast le_rup _ + have a2 := le_lnHi r hr + have hb : (0:ℝ) ≤ b := by exact_mod_cast hb0 + push_cast at a1 + nlinarith + have e := Real.rpow_def_of_pos hrp (b : ℝ) + unfold pHi + have := Real.exp_le_exp.mpr h3 + linarith + +/-! ### 4. F(s) = sum c_r r^s: enclosures of F and F', monotonicity -/ +abbrev CF := List (ℕ × ℤ) +noncomputable def Fc (cf : CF) (s : ℝ) : ℝ := (cf.map fun p => (p.2 : ℝ) * (p.1 : ℝ) ^ s).sum +noncomputable def dFc (cf : CF) (s : ℝ) : ℝ := (cf.map fun p => (p.2 : ℝ) * (Real.log p.1 * (p.1 : ℝ) ^ s)).sum +def okR (cf : CF) : Prop := ∀ p ∈ cf, 1 ≤ p.1 ∧ p.1 ≤ 145 +instance (cf : CF) : Decidable (okR cf) := by unfold okR; infer_instance +/-- upper bound of F on s in [a,b] -/ +def Fup (cf : CF) (a b : ℚ) : ℚ := + (cf.map fun p => if 0 ≤ p.2 then (p.2 : ℚ) * pHi p.1 b else (p.2 : ℚ) * pLo p.1 a).sum +/-- lower bound of F' on s in [a,b] -/ +def dLo (cf : CF) (a b : ℚ) : ℚ := + (cf.map fun p => if 0 ≤ p.2 then (p.2 : ℚ) * (lnLo p.1 * pLo p.1 a) + else (p.2 : ℚ) * (lnHi p.1 * pHi p.1 b)).sum + +theorem Fc_le (cf : CF) (hok : okR cf) (a b : ℚ) (ha : 0 ≤ a) (hb1 : b ≤ 1) (s : ℝ) + (h1 : (a : ℝ) ≤ s) (h2 : s ≤ (b : ℝ)) : Fc cf s ≤ ((Fup cf a b : ℚ) : ℝ) := by + have ha0 : (0:ℝ) ≤ a := by exact_mod_cast ha + have hb0 : 0 ≤ b := by + have : (0:ℝ) ≤ b := by linarith + exact_mod_cast this + induction cf with + | nil => simp [Fc, Fup] + | cons p l ih => + have hp := hok p (by simp) + have hl : okR l := fun q hq => hok q (by simp [hq]) + have ih := ih hl + simp only [Fc, Fup, List.map_cons, List.sum_cons] at ih ⊢ + rw [Rat.cast_add] + have hlo := pow_lo p.1 hp.1 a ha s h1 + have hhi := pow_hi p.1 hp.1 hp.2 b hb0 hb1 s h2 + split_ifs with hc + · have hc' : (0:ℝ) ≤ p.2 := by exact_mod_cast hc + simp only [Rat.cast_mul, Rat.cast_intCast] + nlinarith [mul_le_mul_of_nonneg_left hhi hc'] + · have hc' : (p.2:ℝ) ≤ 0 := by exact_mod_cast (show p.2 ≤ 0 by omega) + simp only [Rat.cast_mul, Rat.cast_intCast] + nlinarith [mul_le_mul_of_nonpos_left hlo hc'] + +theorem dFc_ge (cf : CF) (hok : okR cf) (a b : ℚ) (ha : 0 ≤ a) (hb1 : b ≤ 1) (s : ℝ) + (h1 : (a : ℝ) ≤ s) (h2 : s ≤ (b : ℝ)) : ((dLo cf a b : ℚ) : ℝ) ≤ dFc cf s := by + have ha0 : (0:ℝ) ≤ a := by exact_mod_cast ha + have hb0 : 0 ≤ b := by + have : (0:ℝ) ≤ b := by linarith + exact_mod_cast this + induction cf with + | nil => simp [dFc, dLo] + | cons p l ih => + have hp := hok p (by simp) + have hl : okR l := fun q hq => hok q (by simp [hq]) + have ih := ih hl + simp only [dFc, dLo, List.map_cons, List.sum_cons] at ih ⊢ + rw [Rat.cast_add] + have hlo := pow_lo p.1 hp.1 a ha s h1 + have hhi := pow_hi p.1 hp.1 hp.2 b hb0 hb1 s h2 + have hr1 : (1:ℝ) ≤ p.1 := by exact_mod_cast hp.1 + have hL0 : 0 ≤ Real.log p.1 := Real.log_nonneg hr1 + have hl1 := lnLo_le p.1 hp.1 + have hl2 := le_lnHi p.1 hp.1 + have hn0 : (0:ℝ) ≤ ((lnLo p.1 : ℚ) : ℝ) := by exact_mod_cast lnLo_nonneg p.1 + have hn1 : (0:ℝ) ≤ ((lnHi p.1 : ℚ) : ℝ) := by exact_mod_cast lnHi_nonneg p.1 + have hq0 : (0:ℝ) ≤ ((pLo p.1 a : ℚ) : ℝ) := by + have : 0 ≤ pLo p.1 a := by + unfold pLo eLo + apply rdn_nonneg; apply pow_nonneg; apply rdn_nonneg + unfold eS; apply Finset.sum_nonneg; intro m _ + have : 0 ≤ rdn (a * lnLo p.1) / 8 := div_nonneg (rdn_nonneg (mul_nonneg ha (lnLo_nonneg _))) (by norm_num) + positivity + exact_mod_cast this + have hrs : (0:ℝ) ≤ (p.1 : ℝ) ^ s := by positivity + split_ifs with hc + · have hc' : (0:ℝ) ≤ p.2 := by exact_mod_cast hc + simp only [Rat.cast_mul, Rat.cast_intCast] + have m1 : ((lnLo p.1 : ℚ) : ℝ) * ((pLo p.1 a : ℚ) : ℝ) ≤ Real.log p.1 * (p.1 : ℝ) ^ s := + mul_le_mul hl1 hlo hq0 hL0 + nlinarith [mul_le_mul_of_nonneg_left m1 hc'] + · have hc' : (p.2:ℝ) ≤ 0 := by exact_mod_cast (show p.2 ≤ 0 by omega) + simp only [Rat.cast_mul, Rat.cast_intCast] + have m1 : Real.log p.1 * (p.1 : ℝ) ^ s ≤ ((lnHi p.1 : ℚ) : ℝ) * ((pHi p.1 b : ℚ) : ℝ) := + mul_le_mul hl2 hhi hrs hn1 + nlinarith [mul_le_mul_of_nonpos_left m1 hc'] + +theorem Fc_hasDerivAt (cf : CF) (hok : okR cf) (s : ℝ) : HasDerivAt (Fc cf) (dFc cf s) s := by + induction cf with + | nil => simp only [Fc, dFc, List.map_nil, List.sum_nil]; exact hasDerivAt_const s (0 : ℝ) + | cons p l ih => + have hp := hok p (by simp) + have hl : okR l := fun q hq => hok q (by simp [hq]) + have ih := ih hl + have hrp : (0:ℝ) < p.1 := by have : (1:ℝ) ≤ p.1 := by exact_mod_cast hp.1 + linarith + have h1 := ((Real.hasStrictDerivAt_const_rpow hrp s).hasDerivAt.const_mul (p.2 : ℝ)).add ih + have e : Fc (p :: l) = fun s => (p.2 : ℝ) * (p.1 : ℝ) ^ s + Fc l s := by + funext s; simp [Fc] + have e2 : dFc (p :: l) s = (p.2 : ℝ) * ((p.1 : ℝ) ^ s * Real.log p.1) + dFc l s := by + simp only [dFc, List.map_cons, List.sum_cons]; ring + rw [e, e2]; exact h1 + +/-- if F' >= dLo > 0 on [a,b] then F(s) <= F(b) on [a,b] -/ +theorem Fc_mono (cf : CF) (hok : okR cf) (a b : ℚ) (ha : 0 ≤ a) (hb1 : b ≤ 1) (hd : 0 < dLo cf a b) + (s : ℝ) (h1 : (a : ℝ) ≤ s) (h2 : s ≤ (b : ℝ)) : Fc cf s ≤ Fc cf b := by + have hab : (a : ℝ) ≤ b := le_trans h1 h2 + have hcont : ContinuousOn (Fc cf) (Set.Icc (a : ℝ) b) := + fun x _ => (Fc_hasDerivAt cf hok x).continuousAt.continuousWithinAt + have hm : StrictMonoOn (Fc cf) (Set.Icc (a : ℝ) b) := by + apply strictMonoOn_of_deriv_pos (convex_Icc _ _) hcont + intro x hx + rw [interior_Icc] at hx + rw [(Fc_hasDerivAt cf hok x).deriv] + have := dFc_ge cf hok a b ha hb1 x hx.1.le hx.2.le + have hd' : (0:ℝ) < ((dLo cf a b : ℚ) : ℝ) := by exact_mod_cast hd + linarith + exact hm.monotoneOn ⟨h1, h2⟩ ⟨hab, le_refl _⟩ h2 + +theorem Fc_neg_piece (cf : CF) (hok : okR cf) (a b : ℚ) (ha : 0 ≤ a) (hb1 : b ≤ 1) (h : Fup cf a b < 0) + (s : ℝ) (h1 : (a : ℝ) ≤ s) (h2 : s ≤ (b : ℝ)) : Fc cf s < 0 := by + have := Fc_le cf hok a b ha hb1 s h1 h2 + have h' : ((Fup cf a b : ℚ) : ℝ) < 0 := by exact_mod_cast h + linarith + +end NumCertK + +#print axioms NumCertK.pow_lo +#print axioms NumCertK.pow_hi +#print axioms NumCertK.Fc_mono diff --git a/research/p104-tiered-ceiling/lean/Nov15/NumCertK.md b/research/p104-tiered-ceiling/lean/Nov15/NumCertK.md new file mode 100644 index 0000000000..5bd62abfc0 --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/NumCertK.md @@ -0,0 +1,17 @@ +# NumCertK.lean + NumCertKData.lean + NumCertK22.lean: kernel-checked interval arithmetic; NumCert22 discharged +No sorry, no native_decide; axioms [propext, Classical.choice, Quot.sound] (all three files). Build order: NumCertK (13 s / 2.9 GB), NumCertKData (32 s / 3.4 GB), FloorK22, NumCertK22 (7 s / 2.9 GB); each with `-o .lake/build/lib/lean/Nov15/.olean`. NumCertK22 is a separate file only because importing FloorK22 + the checks in one run exceeds the 3.5 GB guard. + +## Library (NumCertK.lean, Mathlib only) +- ln: chain ln(c+2) = ln(c+1) + 2 atanh(1/(2c+3)) from `Real.hasSum_log_one_add_inv`, 36 terms, explicit geometric tail (`atanh_bounds`), outward rounding to 1e-30 (`rdn`/`rup`). `lnLo r <= ln r <= lnHi r`, r >= 1; accuracy ~1e-28 for r <= 145. +- exp: (Taylor_24(x/8))^8 with `Real.exp_bound'` remainder, outward rounding (`eLo_le`: 0 <= x; `le_eHi`: 0 <= x <= 8). +- **`pow_lo`**: 1 <= r, 0 <= a <= s => pLo r a <= r^s. **`pow_hi`**: 1 <= r <= 145, s <= b <= 1 => r^s <= pHi r b. (s-form: s = 1 - t, so r^(1-t) in [pLo r (1-t_hi), pHi r (1-t_lo)].) Rational, checked by `decide +kernel`. +- F(s) = sum c_r r^s (`Fc`): `Fc_le` (upper enclosure `Fup` on [a,b]), `dFc_ge` (lower enclosure `dLo` of F'), `Fc_hasDerivAt`, `Fc_mono` (dLo > 0 on [a,b] => F(s) <= F(b)). + +## Crossing for K(S22) (NumCertKData.lean, NumCertK22.lean) +- `cfK`: the 17-call invoice caller(6|7) + 17 x nK22, merged by rank: 24 ranks, c_1 = -42272, c_2 = 6494, ..., c_137 = 208 (`invoice_eq_Fc`, simp + ring: identical to the Finv of FloorK22). +- `cfK_neg`: F(s) < 0 for every s in [0, 9939802595/10^10 = 1 - .0060197405]. Proof: six `Fup` boxes cover [0, .9] (grid 0, .45, .6, .7, .8, .85, .9; F <= -3.3e3 at worst); on [.9, s0] one box gives dLo >= 2.5e4 > 0, so F(s) <= F(s0), and the point enclosure gives Fup(s0, s0) < 0 (true F(s0) = -4.83e-6, relative margin 1e-10 of the 2.8e4-sized terms, so the 1e-28 enclosure is ample). +- **`numCert22 : NumCert22 tbar22`** and **`ceiling22_unconditional`**: kappa <= .0060197405 on class K(S22) with NumCert22 discharged; other hypotheses of `ceiling22` unchanged (ClassK22 rank input, cost-model link `hF`). +- The crossing is TRUE: F(1 - .0060197405) = -4.83e-6 (root .00601974047925), F' = 2.33e5 there. + +## Not done +- JointCeiling's `NumCert th0 tbar`: it quantifies over ALL a, b >= 1 (R1 tail Jensen/MVT step, ~1,800 pairs, unaudited per its docstring); the library applies per (a,b) but the infinite tail is not an interval check. WholeFloor's (kappa <= .0204) was not available. diff --git a/research/p104-tiered-ceiling/lean/Nov15/RankLaw.lean b/research/p104-tiered-ceiling/lean/Nov15/RankLaw.lean new file mode 100644 index 0000000000..fd4ec249d3 --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/RankLaw.lean @@ -0,0 +1,597 @@ +import Nov15.TokenCancel +import Mathlib.LinearAlgebra.Matrix.ToLin +import Mathlib.LinearAlgebra.Determinant +import Mathlib.LinearAlgebra.Matrix.Block +import Mathlib.LinearAlgebra.Matrix.Transvection +import Mathlib.LinearAlgebra.Matrix.NonsingularInverse +import Mathlib.LinearAlgebra.Projection +import Mathlib.LinearAlgebra.Isomorphisms +import Mathlib.LinearAlgebra.Dimension.Constructions +import Mathlib.LinearAlgebra.FiniteDimensional.Lemmas + +set_option linter.unusedSectionVars false +namespace RankLaw +open Submodule Module + +section Equiv +variable {K V W : Type*} [Field K] [AddCommGroup V] [Module K V] [AddCommGroup W] [Module K W] + [FiniteDimensional K V] + +/-- Two linear maps out of a finite-dimensional space with the same range differ by an +automorphism of the source. -/ +theorem exists_equiv_comp (f g : V →ₗ[K] W) (h : LinearMap.range f = LinearMap.range g) : + ∃ φ : V ≃ₗ[K] V, f ∘ₗ φ.toLinearMap = g := by + obtain ⟨Qg, hQg⟩ := Submodule.exists_isCompl (LinearMap.ker g) + obtain ⟨Qf, hQf⟩ := Submodule.exists_isCompl (LinearMap.ker f) + have hk : finrank K (LinearMap.ker g) = finrank K (LinearMap.ker f) := by + have h1 := LinearMap.finrank_range_add_finrank_ker f + have h2 := LinearMap.finrank_range_add_finrank_ker g + rw [h] at h1; omega + let e1 : LinearMap.ker g ≃ₗ[K] LinearMap.ker f := LinearEquiv.ofFinrankEq _ _ hk + let e2 : Qg ≃ₗ[K] Qf := + (Submodule.quotientEquivOfIsCompl _ _ hQg).symm ≪≫ₗ g.quotKerEquivRange ≪≫ₗ + (LinearEquiv.ofEq _ _ h.symm) ≪≫ₗ f.quotKerEquivRange.symm ≪≫ₗ + Submodule.quotientEquivOfIsCompl _ _ hQf + let φ : V ≃ₗ[K] V := (Submodule.prodEquivOfIsCompl _ _ hQg).symm ≪≫ₗ (e1.prodCongr e2) ≪≫ₗ + Submodule.prodEquivOfIsCompl _ _ hQf + refine ⟨φ, ?_⟩ + -- key: f (e2 q) = g q + have key : ∀ q : Qg, f (e2 q : V) = g q := by + intro q + set y : Qf := e2 q + have hy : (Submodule.Quotient.mk (y : V) : V ⧸ LinearMap.ker f) = + f.quotKerEquivRange.symm (LinearEquiv.ofEq _ _ h.symm + (g.quotKerEquivRange (Submodule.Quotient.mk (q : V)))) := by + have := Submodule.mk_quotientEquivOfIsCompl_apply hQf + (f.quotKerEquivRange.symm (LinearEquiv.ofEq _ _ h.symm + (g.quotKerEquivRange (Submodule.Quotient.mk (q : V))))) + convert this using 2 + simp [y, e2, Submodule.quotientEquivOfIsCompl_symm_apply] + have := congrArg (fun t => (f.quotKerEquivRange t : W)) hy + simpa using this + apply LinearMap.ext; intro v + obtain ⟨⟨k, q⟩, rfl⟩ := (Submodule.prodEquivOfIsCompl _ _ hQg).surjective v + have hφ : φ ((Submodule.prodEquivOfIsCompl _ _ hQg) (k, q)) = (e1 k : V) + (e2 q : V) := by + simp only [φ, LinearEquiv.trans_apply, LinearEquiv.symm_apply_apply] + rfl + rw [LinearMap.comp_apply, LinearEquiv.coe_coe, hφ, coe_prodEquivOfIsCompl', map_add, map_add] + have hk0 : f (e1 k : V) = 0 := (e1 k).2 + have hg0 : g (k : V) = 0 := k.2 + rw [hk0, hg0, key] +end Equiv + + +section Mix +variable {K G ι : Type*} [Field K] [Fintype G] [DecidableEq G] + +/-- **The V-mix target, as a linear system.** Given the end rows `X` of the registers that end at V +(indexed by `G`) and their target rows `R`, a V mix is an invertible `C` with `C * X = R`. -/ +def VMixM (X R : Matrix G ι K) : Prop := ∃ C : Matrix G G K, IsUnit C.det ∧ C * X = R + +/-- The V-mix system is solvable iff the end rows and the target rows span the same space. -/ +theorem vmixM_iff_span (X R : Matrix G ι K) : + VMixM X R ↔ span K (Set.range X.row) = span K (Set.range R.row) := by + constructor + · rintro ⟨C, hC, hCX⟩ + have hR : ∀ g, R.row g ∈ span K (Set.range X.row) := by + intro g; rw [← hCX] + have : (C * X).row g = Matrix.vecMul (C g) X := rfl + rw [this, ← range_vecMulLinear X]; exact ⟨C g, rfl⟩ + have hX : X = C⁻¹ * R := by rw [← hCX, ← Matrix.mul_assoc, Matrix.nonsing_inv_mul _ hC, Matrix.one_mul] + have hXR : ∀ g, X.row g ∈ span K (Set.range R.row) := by + intro g; rw [hX] + have : (C⁻¹ * R).row g = Matrix.vecMul (C⁻¹ g) R := rfl + rw [this, ← range_vecMulLinear R]; exact ⟨C⁻¹ g, rfl⟩ + apply le_antisymm + · exact span_le.2 (by rintro _ ⟨g, rfl⟩; exact hXR g) + · exact span_le.2 (by rintro _ ⟨g, rfl⟩; exact hR g) + · intro h + have h' : LinearMap.range X.vecMulLinear = LinearMap.range R.vecMulLinear := by + rw [range_vecMulLinear, range_vecMulLinear]; exact h + obtain ⟨φ, hφ⟩ := exists_equiv_comp X.vecMulLinear R.vecMulLinear h' + refine ⟨(LinearMap.toMatrix' φ.toLinearMap).transpose, ?_, ?_⟩ + · rw [Matrix.det_transpose, LinearMap.det_toMatrix'] + exact LinearEquiv.isUnit_det' φ + · ext g j + have e := congrArg (fun F : (G → K) →ₗ[K] (ι → K) => F (Pi.single g 1) j) hφ + simp only [LinearMap.comp_apply, Matrix.vecMulLinear_apply, LinearEquiv.coe_coe] at e + rw [Matrix.single_one_vecMul] at e + have hrow : (fun k => (LinearMap.toMatrix' φ.toLinearMap).transpose g k) = φ (Pi.single g 1) := by + funext k; simp [Matrix.transpose_apply, LinearMap.toMatrix'_apply] + change Matrix.vecMul _ X j = R.row g j + rw [hrow, e] +/-- If the targets are independent, a V mix makes the end rows independent too ("G1 rows are +|G1| independent vectors inside span(G1 targets)"). -/ +theorem vmixM_indep (X R : Matrix G ι K) (h : VMixM X R) (hR : LinearIndependent K R.row) : + LinearIndependent K X.row := by + obtain ⟨C, hC, hCX⟩ := h + have hX : X = C⁻¹ * R := by + rw [← hCX, ← Matrix.mul_assoc, Matrix.nonsing_inv_mul _ hC, Matrix.one_mul] + rw [← Matrix.vecMul_injective_iff] at hR ⊢ + have hCi : Function.Injective (fun v : G → K => Matrix.vecMul v C⁻¹) := + Matrix.vecMul_injective_iff_isUnit.2 ((Matrix.isUnit_iff_isUnit_det _).2 ((Matrix.isUnit_nonsing_inv_det_iff).2 hC)) + intro v w hvw + apply hCi; apply hR + simpa [hX, Matrix.vecMul_vecMul] using hvw + +/-- **Uniqueness.** With independent end rows, the V mix is unique. -/ +theorem vmixM_unique (X R : Matrix G ι K) (hX : LinearIndependent K X.row) + (C C' : Matrix G G K) (h : C * X = R) (h' : C' * X = R) : C = C' := by + rw [← Matrix.vecMul_injective_iff] at hX + ext g h0 + have : Matrix.vecMul (C g) X = Matrix.vecMul (C' g) X := by + have e1 : (C * X).row g = Matrix.vecMul (C g) X := rfl + have e2 : (C' * X).row g = Matrix.vecMul (C' g) X := rfl + rw [← e1, ← e2, h, h'] + exact congrFun (hX this) h0 + +/-- **Token order affects only fill.** `vmixM_iff_span` (and `rank_law`) carry no order hypothesis: +existence of the V mix does not depend on any carrier/token order. An order only shapes `C`: +if the end rows are a block-triangular (w.r.t. the order `b`) invertible recombination of the +targets, the V mix is block-triangular, so it has no fill outside the triangle. -/ +theorem vmixM_fill {α : Type*} [LinearOrder α] (b : G → α) (X R : Matrix G ι K) + (Tg : Matrix G G K) (hT : Tg.BlockTriangular b) (hdet : IsUnit Tg.det) (hX : X = Tg * R) : + ∃ C : Matrix G G K, IsUnit C.det ∧ C * X = R ∧ C.BlockTriangular b := by + letI := Matrix.invertibleOfIsUnitDet Tg hdet + refine ⟨Tg⁻¹, (Matrix.isUnit_nonsing_inv_det_iff).2 hdet, ?_, + Matrix.blockTriangular_inv_of_blockTriangular hT⟩ + rw [hX, ← Matrix.mul_assoc, Matrix.nonsing_inv_mul _ hdet, Matrix.one_mul] + +/-- **Realisability by V-hub ops.** Every V mix factors into transvections (ADD i += c·j between +two V-enders), a diagonal with nonzero entries (SCALEs), and transvections. -/ +theorem vmix_ops (Cm : Matrix G G K) (hC : IsUnit Cm.det) : + ∃ (L L' : List (Matrix.TransvectionStruct G K)) (D : G → K), (∀ g, D g ≠ 0) ∧ + Cm = (L.map Matrix.TransvectionStruct.toMatrix).prod * Matrix.diagonal D * + (L'.map Matrix.TransvectionStruct.toMatrix).prod := by + obtain ⟨L, L', D, hM⟩ := Matrix.Pivot.exists_list_transvec_mul_diagonal_mul_list_transvec Cm + refine ⟨L, L', D, fun g hg => ?_, hM⟩ + have hdet : Cm.det = ∏ g, D g := by + rw [hM, Matrix.det_mul, Matrix.det_mul, Matrix.TransvectionStruct.det_toMatrix_prod, + Matrix.TransvectionStruct.det_toMatrix_prod, Matrix.det_diagonal]; simp + rw [hdet] at hC + exact hC.ne_zero (Finset.prod_eq_zero (Finset.mem_univ g) hg) + +end Mix + +section Run +open TokenCancel +variable {K Reg C : Type*} [Field K] [Fintype Reg] [DecidableEq Reg] [DecidableEq C] + +/-- Span of the rows of a state. -/ +abbrev Sp (s : St K Reg C) : Submodule K (Reg → K) := span K (Set.range s.row) + +/-- Rows of the other registers. -/ +abbrev Oth (s : St K Reg C) (i : Reg) : Submodule K (Reg → K) := span K (s.row '' {r | r ≠ i}) + +theorem span_range_update (f : Reg → Reg → K) (i : Reg) (v : Reg → K) : + span K (Set.range (Function.update f i v)) = span K (f '' {r | r ≠ i}) ⊔ K ∙ v := by + have : Set.range (Function.update f i v) = f '' {r | r ≠ i} ∪ {v} := by + ext x; constructor + · rintro ⟨r, rfl⟩ + by_cases hr : r = i + · subst hr; simp + · left; exact ⟨r, hr, by simp [Function.update_of_ne hr]⟩ + · rintro (⟨r, hr, rfl⟩ | hx) + · exact ⟨r, by simp [Function.update_of_ne (show r ≠ i from hr)]⟩ + · rw [Set.mem_singleton_iff] at hx; exact ⟨i, by simp [hx]⟩ + rw [this, span_union] + +theorem span_range_eq (f : Reg → Reg → K) (i : Reg) : + span K (Set.range f) = span K (f '' {r | r ≠ i}) ⊔ K ∙ f i := by + conv_lhs => rw [show f = Function.update f i (f i) by simp] + exact span_range_update f i (f i) + +theorem sup_singleton_add (S : Submodule K (Reg → K)) (x w : Reg → K) (hw : w ∈ S) : + S ⊔ K ∙ (x + w) = S ⊔ K ∙ x := by + apply le_antisymm + · refine sup_le le_sup_left ((span_singleton_le_iff_mem _ _).2 ?_) + exact add_mem (mem_sup_right (mem_span_singleton_self x)) (mem_sup_left hw) + · refine sup_le le_sup_left ((span_singleton_le_iff_mem _ _).2 ?_) + have h := sub_mem (mem_sup_right (mem_span_singleton_self (x + w)) : x + w ∈ S ⊔ K ∙ (x + w)) + (mem_sup_left hw : w ∈ S ⊔ K ∙ (x + w)) + simpa using h + +/-- A loss of rank: CLEAR or COPY (onto a different source) of a row that is not in the span of +the other rows at that instant. -/ +def Lossy (s : St K Reg C) : Ev K Reg C → Prop + | .clear i _ => s.row i ∉ Oth s i + | .copy i j _ => i ≠ j ∧ s.row i ∉ Oth s i + | _ => False + +/-- A loss somewhere along the run. -/ +def Loss : St K Reg C → List (Ev K Reg C) → Prop + | _, [] => False + | s, e :: es => Lossy s e ∨ Loss (step s e) es + +/-- Every SCALE factor is nonzero (a SCALE by 0 is a CLEAR). -/ +def NZ : Ev K Reg C → Prop + | .scale _ u _ => u ≠ 0 + | _ => True + +/-- Tokens: registers present at the start plus registers born so far. -/ +def tokStep (T : Finset Reg) : Ev K Reg C → Finset Reg + | .born i _ => insert i T + | _ => T + +def tokRun (T : Finset Reg) : List (Ev K Reg C) → Finset Reg + | [] => T + | e :: es => tokRun (tokStep T e) es + +/-- Token span. -/ +abbrev TS (T : Finset Reg) : Submodule K (Reg → K) := + span K ((fun r => (Pi.single r (1 : K) : Reg → K)) '' (T : Set Reg)) + +theorem finrank_TS (T : Finset Reg) : finrank K (TS (K := K) T) = T.card := by + let b : T → Reg → K := fun r => Pi.single (r : Reg) (1 : K) + have hb : LinearIndependent K b := by + have := (Pi.basisFun K Reg).linearIndependent.comp (Subtype.val : T → Reg) Subtype.val_injective + convert this using 1; funext r; simp [b, Pi.basisFun_apply] + have hr : Set.range b = (fun r => (Pi.single r (1 : K) : Reg → K)) '' (T : Set Reg) := by + ext x; simp [b] + have := finrank_span_eq_card hb + rw [hr] at this + rw [this, Fintype.card_coe] + +variable (z V : C) + +/-- Bookkeeping invariant: absent registers have row 0; tokens are present registers. -/ +def Good (s : St K Reg C) (T : Finset Reg) : Prop := + (∀ r, s.loc r = none → s.row r = 0) ∧ (∀ r ∈ T, s.loc r ≠ none) + +theorem good_step (s : St K Reg C) (T : Finset Reg) (e : Ev K Reg C) + (hL : LegalEv z V s e) (hG : Good s T) : Good (step s e) (tokStep T e) := by + obtain ⟨h1, h2⟩ := hG + cases e with + | born i c => + refine ⟨fun r hr => ?_, fun r hr => ?_⟩ + · by_cases hri : r = i + · subst hri; simp [step] at hr + · simp only [step, Function.update_of_ne hri] at hr ⊢; exact h1 r hr + · by_cases hri : r = i + · subst hri; simp [step] + · simp only [tokStep, Finset.mem_insert, hri, false_or] at hr + simp only [step, Function.update_of_ne hri]; exact h2 r hr + | init i c => + refine ⟨fun r hr => ?_, fun r hr => ?_⟩ + · by_cases hri : r = i + · subst hri; simp [step] + · simp only [step, Function.update_of_ne hri] at hr ⊢; exact h1 r hr + · by_cases hri : r = i + · subst hri; simp [step] + · simp only [step, Function.update_of_ne hri]; exact h2 r hr + | move i c => + refine ⟨fun r hr => ?_, fun r hr => ?_⟩ + · by_cases hri : r = i + · subst hri; simp [step] at hr + · simp only [step, Function.update_of_ne hri] at hr ⊢; exact h1 r hr + · by_cases hri : r = i + · subst hri; simp [step] + · simp only [step, Function.update_of_ne hri]; exact h2 r hr + | add i j a c => + obtain ⟨-, hi, -⟩ := hL + refine ⟨fun r hr => ?_, h2⟩ + by_cases hri : r = i + · subst hri; simp [step, hi] at hr + · simp only [step, Function.update_of_ne hri] at hr ⊢; exact h1 r hr + | scale i u c => + have hi : s.loc i = some c := hL + refine ⟨fun r hr => ?_, h2⟩ + by_cases hri : r = i + · subst hri; simp only [step] at hr; rw [hi] at hr; exact absurd hr (by simp) + · simp only [step, Function.update_of_ne hri] at hr ⊢; exact h1 r hr + | clear i c => + refine ⟨fun r hr => ?_, h2⟩ + by_cases hri : r = i + · subst hri; simp [step] + · simp only [step, Function.update_of_ne hri] at hr ⊢; exact h1 r hr + | copy i j c => + obtain ⟨hi, -⟩ := hL + refine ⟨fun r hr => ?_, h2⟩ + by_cases hri : r = i + · subst hri; simp [step, hi] at hr + · simp only [step, Function.update_of_ne hri] at hr ⊢; exact h1 r hr + +theorem Sp_eq_oth (s : St K Reg C) (i : Reg) : Sp s = Oth s i ⊔ K ∙ s.row i := + span_range_eq s.row i + +theorem Sp_update (s : St K Reg C) (i : Reg) (v : Reg → K) (l : Reg → Option C) : + Sp (⟨Function.update s.row i v, l⟩ : St K Reg C) = Oth s i ⊔ K ∙ v := + span_range_update s.row i v + +theorem mem_oth (s : St K Reg C) {i j : Reg} (h : j ≠ i) : s.row j ∈ Oth s i := + subset_span ⟨j, h, rfl⟩ + +/-- **Only CLEAR (and COPY) can lose rank.** Every non-birth op keeps the row span inside the +old one. -/ +theorem Sp_step_le (s : St K Reg C) (T : Finset Reg) (e : Ev K Reg C) (hb : ∀ i c, e ≠ .born i c) + (hL : LegalEv z V s e) (hG : Good s T) : Sp (step s e) ≤ Sp s := by + cases e with + | born i c => exact absurd rfl (hb i c) + | init i c => + have h0 : s.row i = 0 := hG.1 i hL + simp only [step]; rw [Sp_update, Sp_eq_oth s i, h0] + | move i c => exact le_rfl + | add i j a c => + simp only [step]; rw [Sp_update, Sp_eq_oth s i, + sup_singleton_add _ _ _ (smul_mem _ _ (mem_oth s (Ne.symm hL.1)))] + | scale i u c => + simp only [step]; rw [Sp_update, Sp_eq_oth s i] + exact sup_le_sup_left ((span_singleton_le_iff_mem _ _).2 + (smul_mem _ _ (mem_span_singleton_self _))) _ + | clear i c => + simp only [step]; rw [Sp_update, Sp_eq_oth s i, span_singleton_eq_bot.2 rfl, sup_bot_eq] + exact le_sup_left + | copy i j c => + simp only [step]; rw [Sp_update, Sp_eq_oth s i] + by_cases hij : j = i + · subst hij; exact le_rfl + · exact sup_le le_sup_left (le_trans ((span_singleton_le_iff_mem _ _).2 (mem_oth s hij)) + le_sup_left) + +theorem TS_insert (T : Finset Reg) (i : Reg) : + TS (K := K) (insert i T) = TS (K := K) T ⊔ K ∙ (Pi.single i (1 : K) : Reg → K) := by + simp only [TS, Finset.coe_insert, Set.image_insert_eq, span_insert]; exact sup_comm _ _ + +/-- A non-lossy step keeps the row span equal to the token span (SCALE factors nonzero). -/ +theorem Sp_step_noloss (s : St K Reg C) (T : Finset Reg) (e : Ev K Reg C) + (hL : LegalEv z V s e) (hN : NZ e) (hG : Good s T) (hS : Sp s = TS T) (hl : ¬ Lossy s e) : + Sp (step s e) = TS (tokStep T e) := by + cases e with + | born i c => + have h0 : s.row i = 0 := hG.1 i hL + have : Sp s = Oth s i := by rw [Sp_eq_oth s i, h0, span_singleton_eq_bot.2 rfl, sup_bot_eq] + simp only [step, tokStep]; rw [Sp_update, TS_insert, ← hS, this] + | init i c => + have h0 : s.row i = 0 := hG.1 i hL + simp only [step, tokStep]; rw [Sp_update, ← hS, Sp_eq_oth s i, h0] + | move i c => exact hS + | add i j a c => + simp only [step, tokStep]; rw [Sp_update, ← hS, Sp_eq_oth s i, + sup_singleton_add _ _ _ (smul_mem _ _ (mem_oth s (Ne.symm hL.1)))] + | scale i u c => + simp only [step, tokStep]; rw [Sp_update, ← hS, Sp_eq_oth s i, + span_singleton_smul_eq (IsUnit.mk0 _ hN)] + | clear i c => + have hm : s.row i ∈ Oth s i := not_not.1 hl + simp only [step, tokStep]; rw [Sp_update, ← hS, Sp_eq_oth s i, span_singleton_eq_bot.2 rfl, + sup_bot_eq, sup_eq_left.2 ((span_singleton_le_iff_mem _ _).2 hm)] + | copy i j c => + simp only [step, tokStep] + by_cases hij : j = i + · subst hij; simpa using hS + · have hm : s.row i ∈ Oth s i := by + by_contra h; exact hl ⟨Ne.symm hij, h⟩ + rw [Sp_update, ← hS, Sp_eq_oth s i, sup_eq_left.2 ((span_singleton_le_iff_mem _ _).2 hm), + sup_eq_left.2 ((span_singleton_le_iff_mem _ _).2 (mem_oth s hij))] + +open Classical in +/-- Rank bookkeeping for one step: rank + tokens never gains, and a lossy step loses one. -/ +theorem rank_step (s : St K Reg C) (T : Finset Reg) (e : Ev K Reg C) + (hL : LegalEv z V s e) (hG : Good s T) : + finrank K (Sp (step s e)) + T.card + (if Lossy s e then 1 else 0) ≤ + finrank K (Sp s) + (tokStep T e).card := by + classical + by_cases hb : ∃ i c, e = .born i c + · obtain ⟨i, c, rfl⟩ := hb + have hloc : s.loc i = none := hL + have h0 : s.row i = 0 := hG.1 i hloc + have hiT : i ∉ T := fun h => hG.2 i h hloc + have hl : ¬ Lossy s (.born i c : Ev K Reg C) := id + simp only [hl, if_false, add_zero, tokStep, Finset.card_insert_of_notMem hiT] + have hS : Sp s = Oth s i := by rw [Sp_eq_oth s i, h0, span_singleton_eq_bot.2 rfl, sup_bot_eq] + have hE : Sp (step s (.born i c)) = Oth s i ⊔ K ∙ (Pi.single i (1:K) : Reg → K) := by + simp only [step]; rw [Sp_update] + have e1 := congrArg (fun S : Submodule K (Reg → K) => finrank K S) hE + have e2 := congrArg (fun S : Submodule K (Reg → K) => finrank K S) hS + have := Submodule.finrank_add_le_finrank_add_finrank (Oth s i) (K ∙ (Pi.single i (1:K) : Reg → K)) + have hv : (Pi.single i (1:K) : Reg → K) ≠ 0 := fun h => by simpa using congrFun h i + have h1 := finrank_span_singleton (K := K) hv + omega + · push Not at hb + have hle := Sp_step_le z V s T e hb hL hG + have hT : tokStep T e = T := by cases e <;> simp_all [tokStep] + rw [hT] + by_cases hl : Lossy s e + · simp only [hl, if_true] + have hlt : Sp (step s e) < Sp s := by + refine lt_of_le_of_ne hle (fun heq => ?_) + cases e with + | clear i c => + apply hl + have : s.row i ∈ Sp s := subset_span ⟨i, rfl⟩ + rw [← heq] at this; simp only [step] at this + rw [Sp_update, span_singleton_eq_bot.2 rfl, sup_bot_eq] at this; exact this + | copy i j c => + apply hl.2 + have : s.row i ∈ Sp s := subset_span ⟨i, rfl⟩ + rw [← heq] at this; simp only [step] at this + rwa [Sp_update, sup_eq_left.2 ((span_singleton_le_iff_mem _ _).2 (mem_oth s hl.1.symm))] + at this + | _ => exact hl.elim + have := Submodule.finrank_lt_finrank_of_lt hlt + omega + · simp only [hl, if_false] + have := Submodule.finrank_mono hle + omega + +/-- No loss along a legal run (SCALE factors nonzero): the final row span is the token span. -/ +theorem span_run (s : St K Reg C) (T : Finset Reg) (evs : List (Ev K Reg C)) + (hL : Legal z V s evs) (hN : ∀ e ∈ evs, NZ e) (hG : Good s T) (hS : Sp s = TS T) + (hl : ¬ Loss s evs) : Sp (run s evs) = TS (tokRun T evs) := by + induction evs generalizing s T with + | nil => exact hS + | cons e es ih => + simp only [Loss, not_or] at hl + exact ih (step s e) (tokStep T e) hL.2 (fun e' he' => hN e' (List.mem_cons_of_mem _ he')) + (good_step z V s T e hL.1 hG) + (Sp_step_noloss z V s T e hL.1 (hN e List.mem_cons_self) hG hS hl.1) hl.2 + +/-- Rank bookkeeping along a legal run: any slack m is kept, and a loss adds one more unit. -/ +theorem rank_run (s : St K Reg C) (T : Finset Reg) (evs : List (Ev K Reg C)) + (hL : Legal z V s evs) (hG : Good s T) (m : ℕ) (hm : finrank K (Sp s) + m ≤ T.card) : + finrank K (Sp (run s evs)) + m ≤ (tokRun T evs).card ∧ + (Loss s evs → finrank K (Sp (run s evs)) + m + 1 ≤ (tokRun T evs).card) := by + induction evs generalizing s T m with + | nil => exact ⟨hm, fun h => h.elim⟩ + | cons e es ih => + simp only [run, tokRun] + have hst := rank_step z V s T e hL.1 hG + have hG' := good_step z V s T e hL.1 hG + by_cases hl : Lossy s e + · simp only [hl, if_true] at hst + have := (ih (step s e) (tokStep T e) hL.2 hG' (m + 1) (by omega)).1 + exact ⟨le_trans (Nat.le_succ _) this, fun _ => this⟩ + · simp only [hl, if_false, add_zero] at hst + have := ih (step s e) (tokStep T e) hL.2 hG' m (by omega) + refine ⟨this.1, fun hlo => ?_⟩ + simp only [Loss, hl, false_or] at hlo + exact this.2 hlo + +/-- **Rank is lost exactly at lossy CLEAR/COPY.** For a legal run from a state whose rows span its +tokens (all SCALE factors nonzero), the final row span equals the final token span iff the run +contains no lossy event. -/ +theorem full_rank_iff_noloss (s : St K Reg C) (T : Finset Reg) (evs : List (Ev K Reg C)) + (hL : Legal z V s evs) (hN : ∀ e ∈ evs, NZ e) (hG : Good s T) (hS : Sp s = TS T) : + Sp (run s evs) = TS (tokRun T evs) ↔ ¬ Loss s evs := by + refine ⟨fun h hl => ?_, span_run z V s T evs hL hN hG hS⟩ + have h0 : finrank K (Sp s) + 0 ≤ T.card := by + rw [hS, finrank_TS]; simp + have := (rank_run z V s T evs hL hG 0 h0).2 hl + have e := congrArg (fun S : Submodule K (Reg → K) => finrank K S) h + rw [e, finrank_TS] at this + omega + +/-- Cancellation: two subspaces of `U` with the same sum against a complement-to-`U` piece agree. -/ +theorem eq_of_sup_eq {M : Type*} [AddCommGroup M] [Module K M] (A B N U : Submodule K M) + (hA : A ≤ U) (hB : B ≤ U) (hUN : U ⊓ N = ⊥) (h : A ⊔ N = B ⊔ N) : A = B := by + have key : ∀ A B : Submodule K M, A ≤ U → B ≤ U → A ⊔ N = B ⊔ N → A ≤ B := by + intro A B hA hB h x hx + have : x ∈ B ⊔ N := h ▸ mem_sup_left hx + obtain ⟨b, hb, n, hn, rfl⟩ := mem_sup.1 this + have hnU : n ∈ U := by + have := sub_mem (hA hx) (hB hb); simpa using this + have : n ∈ U ⊓ N := ⟨hnU, hn⟩ + rw [hUN, mem_bot] at this; subst this; simpa using hb + exact le_antisymm (key A B hA hB h) (key B A hB hA h.symm) + +theorem span_range_split (f : Reg → Reg → K) (G1 : Finset Reg) : + span K (Set.range f) = span K (f '' (G1 : Set Reg)) ⊔ span K (f '' (G1 : Set Reg)ᶜ) := by + rw [← span_union, ← Set.image_union, Set.union_compl_self, Set.image_univ] + +theorem range_restrict (f : Reg → Reg → K) (G1 : Finset Reg) : + Set.range (Matrix.of fun g : G1 => f g).row = f '' (G1 : Set Reg) := by + ext x; constructor + · rintro ⟨g, rfl⟩; exact ⟨g, g.2, rfl⟩ + · rintro ⟨g, hg, rfl⟩; exact ⟨⟨g, hg⟩, rfl⟩ + +/-- The V mix of a run: an invertible `C` over the registers `G1` that end at V with +`C · X[G1] = Rf[G1]`, where `X` are the end rows of the run (all V-hub ops deleted). -/ +def VMix (X Rf : Reg → Reg → K) (G1 : Finset Reg) : Prop := + VMixM (Matrix.of fun g : G1 => X g) (Matrix.of fun g : G1 => Rf g) + +/-- **RANK law (internal notes).** Run a legal word (V-hub ops deleted, SCALE factors +nonzero) from a state whose rows span its tokens. Let `G1` end at V; assume every other register +already ends at its target (`hNon`), and the target end state has full token rank (`hTgt`). +Let `U` be the "zero-W0" subspace (T_X + tokens): it contains the V targets (`hRU`) and meets the +span of the non-V targets only in 0 (`hUN`). Then a V mix exists iff +(i) no CLEAR/COPY loses rank and (ii) every V-ender row lies in `U`. -/ +theorem rank_law (s : St K Reg C) (T : Finset Reg) (evs : List (Ev K Reg C)) + (hL : Legal z V s evs) (hN : ∀ e ∈ evs, NZ e) (hG : Good s T) (hS : Sp s = TS T) + (Rf : Reg → Reg → K) (G1 : Finset Reg) (U : Submodule K (Reg → K)) + (hNon : ∀ r ∉ G1, (run s evs).row r = Rf r) + (hTgt : span K (Set.range Rf) = TS (tokRun T evs)) + (hRU : ∀ g ∈ G1, Rf g ∈ U) + (hUN : U ⊓ span K (Rf '' (G1 : Set Reg)ᶜ) = ⊥) : + VMix (run s evs).row Rf G1 ↔ ¬ Loss s evs ∧ ∀ g ∈ G1, (run s evs).row g ∈ U := by + set X := (run s evs).row with hXdef + have hNim : X '' (G1 : Set Reg)ᶜ = Rf '' (G1 : Set Reg)ᶜ := + Set.image_congr (fun r hr => hNon r (by simpa using hr)) + have hBU : span K (Rf '' (G1 : Set Reg)) ≤ U := + span_le.2 (by rintro _ ⟨g, hg, rfl⟩; exact hRU g hg) + unfold VMix + rw [vmixM_iff_span, range_restrict, range_restrict] + constructor + · intro hAB + have hfull : Sp (run s evs) = TS (tokRun T evs) := by + rw [← hTgt, Sp, ← hXdef, span_range_split X G1, span_range_split Rf G1, hAB, hNim] + refine ⟨(full_rank_iff_noloss z V s T evs hL hN hG hS).1 hfull, fun g hg => ?_⟩ + exact hBU (hAB ▸ subset_span ⟨g, hg, rfl⟩) + · rintro ⟨hl, hU⟩ + have hfull := span_run z V s T evs hL hN hG hS hl + have hsum : span K (X '' (G1 : Set Reg)) ⊔ span K (Rf '' (G1 : Set Reg)ᶜ) = + span K (Rf '' (G1 : Set Reg)) ⊔ span K (Rf '' (G1 : Set Reg)ᶜ) := by + rw [← hNim, ← span_range_split X G1, hNim, ← span_range_split Rf G1, hTgt]; exact hfull + exact eq_of_sup_eq _ _ _ U (span_le.2 (by rintro _ ⟨g, hg, rfl⟩; exact hU g hg)) hBU hUN hsum + +/-- ADD and SCALE (nonzero) are invertible ops: an inverse op restores the state exactly. -/ +theorem add_inverse (s : St K Reg C) (i j : Reg) (a : K) (c : C) (hij : i ≠ j) : + step (step s (.add i j a c)) (.add i j (-a) c) = s := by + obtain ⟨row, loc⟩ := s + simp only [step, St.mk.injEq, and_true] + funext r; by_cases hr : r = i + · subst hr; simp [Function.update_of_ne (Ne.symm hij)] + · simp [Function.update_of_ne hr] + +theorem scale_inverse (s : St K Reg C) (i : Reg) (u : K) (c : C) (hu : u ≠ 0) : + step (step s (.scale i u c)) (.scale i u⁻¹ c) = s := by + obtain ⟨row, loc⟩ := s + simp only [step, St.mk.injEq, and_true] + funext r; by_cases hr : r = i + · subst hr; simp [smul_smul, inv_mul_cancel₀ hu] + · simp [Function.update_of_ne hr] + +/-- The canonical start: present registers carry their own coordinate, absent ones 0. -/ +def start (l : Reg → Option C) : St K Reg C := + ⟨fun r => if l r = none then 0 else Pi.single r 1, l⟩ + +def startTok (l : Reg → Option C) : Finset Reg := Finset.univ.filter fun r => l r ≠ none + +theorem start_good (l : Reg → Option C) : Good (start (K := K) l) (startTok l) := + ⟨fun r hr => by simp only [start] at hr ⊢; simp [hr], fun r hr => by simpa [start, startTok] using hr⟩ + +theorem start_span (l : Reg → Option C) : Sp (start (K := K) l) = TS (startTok l) := by + apply le_antisymm + · refine span_le.2 ?_ + rintro _ ⟨r, rfl⟩ + by_cases hr : l r = none + · simp [start, hr] + · simp only [start, hr, if_false] + exact subset_span ⟨r, by simpa [startTok] using hr, rfl⟩ + · refine span_le.2 ?_ + rintro _ ⟨r, hr, rfl⟩ + have hr' : l r ≠ none := by simpa [startTok] using hr + exact subset_span ⟨r, by simp [start, hr']⟩ + +/-- **Finding: COPY is not invertible either.** The prose lists CLEAR as the only rank-losing op; +in the op model with COPY (i := j's row), COPY onto a row outside the others' span loses rank. -/ +theorem copy_lossy_example : + Lossy (start (K := ℚ) (C := Unit) (fun _ : Fin 2 => some ())) (.copy 0 1 ()) := by + refine ⟨by decide, fun h => ?_⟩ + have himg : (start (K := ℚ) (C := Unit) (fun _ : Fin 2 => some ())).row '' {r | r ≠ 0} = + {Pi.single 1 1} := by + ext x; simp only [Set.mem_image, Set.mem_ofPred_eq, Set.mem_singleton_iff, start] + constructor + · rintro ⟨r, hr, rfl⟩ + have : r = 1 := by fin_cases r <;> simp_all + subst this; simp + · rintro rfl; exact ⟨1, by decide, by simp⟩ + rw [Oth, himg, mem_span_singleton] at h + obtain ⟨a, ha⟩ := h + have := congrFun ha 0 + simp [start] at this + +end Run + +end RankLaw + +#print axioms RankLaw.rank_law +#print axioms RankLaw.full_rank_iff_noloss +#print axioms RankLaw.vmixM_iff_span +#print axioms RankLaw.vmixM_fill +#print axioms RankLaw.vmix_ops +#print axioms RankLaw.vmixM_unique +#print axioms RankLaw.vmixM_indep +#print axioms RankLaw.copy_lossy_example +#print axioms RankLaw.add_inverse +#print axioms RankLaw.scale_inverse +#print axioms RankLaw.start_span diff --git a/research/p104-tiered-ceiling/lean/Nov15/RankLaw.md b/research/p104-tiered-ceiling/lean/Nov15/RankLaw.md new file mode 100644 index 0000000000..fbd610a6ce --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/RankLaw.md @@ -0,0 +1,48 @@ +# RankLaw.lean: rebuild's RANK law (RESULT §7, internal log CORE r2). No sorry, ~7 s, 2.2 GB RSS +Source: internal notes §7 and the CORE r2 line in internal log.md. +Axioms: [propext, Classical.choice, Quot.sound]. + +Build (imports the TokenCancel olean): + lake env lean -o .lake/build/lib/lean/Nov15/TokenCancel.olean Nov15/TokenCancel.lean + lake env lean -o .lake/build/lib/lean/Nov15/RankLaw.olean Nov15/RankLaw.lean + +**Model.** TokenCancel's op model and legality (born/init/move/add/scale/clear/copy, co-presence; z, V arbitrary). +- Tokens = registers present at the start plus births so far (`tokRun`). Token span `TS T` = span of the e_r, r ∈ T, with `finrank_TS` = |T|. +- `Good`: absent registers have row 0 and tokens are present. `start l` (own coordinate if present, 0 if absent) satisfies `Good`, and its rows span its tokens (`start_good`, `start_span`). +- `Lossy s e`: a CLEAR of i, or a COPY into i from j ≠ i, while row i ∉ span(other rows) at that instant. `Loss` = some lossy event in the run. `NZ`: SCALE factor ≠ 0. + +**The V-mix target (a linear system).** `VMixM X R` := ∃ C, det C a unit, C·X = R. X = end rows of the V-enders G1 after a run with the V-hub ops deleted, R = their targets. +- `vmixM_iff_span`: solvable iff rowspan X = rowspan R. Built on `exists_equiv_comp`: two maps with equal range differ by an automorphism. +- `vmix_ops`: every such C is a product transvections · diag(D) · transvections with all D ≠ 0, i.e. V-hub ADDs and nonzero SCALEs (Mathlib Pivot). +- `vmixM_indep`: independent targets imply independent end rows. `vmixM_unique`: independent end rows make C unique. + +**Only CLEAR (and COPY) lose rank.** +- `add_inverse` and `scale_inverse` (u ≠ 0): the inverse op restores the state exactly. +- `Sp_step_le`: no non-birth op enlarges the row span. +- `rank_step`, `rank_run`: (row rank) + (slack) never exceeds |tokens|, and a lossy step costs one unit for good. +- `span_run`: with no loss, end row span = token span. +- `full_rank_iff_noloss`: end row span = token span ⟺ no lossy CLEAR/COPY. + +**`rank_law` (the iff).** Assume: +- a legal run with NZ, from a state whose rows span its tokens; +- non-V registers already end on their targets (`hNon`); +- the target end state spans the final tokens (`hTgt`; true when the target is the end of any loss-free legal word with the same births, by `span_run`); +- U ⊇ V targets (`hRU`), and U ∩ span(non-V targets) = 0 (`hUN`). + +Then: V mix exists ⟺ (i) no lossy CLEAR/COPY and (ii) every V-ender end row ∈ U. + +**Token order** (`vmixM_fill` + the shape of `rank_law`). +- Neither existence statement has an order hypothesis, so correctness never depends on the LATE order. +- An order b only shapes C: if X = T·R with T block-triangular for b and invertible, then the V mix C = T⁻¹ is block-triangular. No fill outside the triangle. + +**Findings (prose statements false or underspecified as written).** +1. **"Every op except CLEAR is invertible" is false with COPY.** `copy_lossy_example` (over ℚ, 2 registers): COPY 0←1 is lossy. + - Also SCALE by 0 is a CLEAR. + - Minimal fix: "every op except CLEAR, COPY-over-a-live-row and SCALE 0", or treat COPY as CLEAR + ADD. The law then holds verbatim with Lossy covering COPY. + - #7623 behaviour is unaffected if its words contain no such COPY. Not checked here. +2. **(ii) "zero W0 part" is only the right criterion relative to a U that meets the span of the non-V targets trivially (`hUN`).** Without that, the iff fails. + - Hand example: G1 = {g}, N = {n}, Rf g = e1, Rf n = e2, U = everything, X g = e1 + e2. There is no loss and X g ∈ U, but X g ∉ span{e1}. + - The "only if" of (i) also needs `hTgt`, the target state's full token rank. +3. "The V mix is unique" needs independent end rows. rank X[G1] = |G1| was checked [C] on #7623. + +**Scope.** "Owned" is not used; the law holds for any register. The W0/T_X split enters only through U. diff --git a/research/p104-tiered-ceiling/lean/Nov15/RankLawC.lean b/research/p104-tiered-ceiling/lean/Nov15/RankLawC.lean new file mode 100644 index 0000000000..5c72771505 --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/RankLawC.lean @@ -0,0 +1,167 @@ +/- +RankLaw (c) fix, See RankLawC.md. + +`rank_law` needs U ⊓ span(non-V targets) = ⊥. This file drops that hypothesis: +* `rank_law_gen`: with no U at all, V mix ⟺ no loss ∧ every V-ender row ∈ B ∧ B ⊓ N ≤ A + (B = span V targets, N = span non-V targets, A = span V-ender rows). +* `rank_law_proj`: for any U ⊇ B and any linear π vanishing on B and injective on U ⊓ N, + condition (ii) becomes "row ∈ U and π(row) = 0" (the (U ⊓ N)-component vanishes). +* `rank_law_indep`: if B ⊓ N = ⊥ (independent targets) the third clause disappears. +* `rank_law_of_gen`: the original `rank_law` is the case π = 0. + +Build (imports the RankLaw olean, itself built on TokenCancel): + lake env lean -o .lake/build/lib/lean/Nov15/TokenCancel.olean Nov15/TokenCancel.lean + lake env lean -o .lake/build/lib/lean/Nov15/RankLaw.olean Nov15/RankLaw.lean + lake env lean -o .lake/build/lib/lean/Nov15/RankLawC.olean Nov15/RankLawC.lean +-/ +import Nov15.RankLaw + +set_option linter.unusedSectionVars false + +namespace RankLawC +open Submodule Module TokenCancel RankLaw + +section Lat +variable {K M : Type*} [Field K] [AddCommGroup M] [Module K M] + +/-- Cancellation without a complement: given A ⊔ N = B ⊔ N, A = B iff A ≤ B and B ⊓ N ≤ A. -/ +theorem eq_iff_of_sup_eq (A B N : Submodule K M) (h : A ⊔ N = B ⊔ N) : + A = B ↔ A ≤ B ∧ B ⊓ N ≤ A := by + constructor + · rintro rfl; exact ⟨le_rfl, inf_le_left⟩ + · rintro ⟨hAB, hBN⟩ + refine le_antisymm hAB fun b hb => ?_ + have : b ∈ A ⊔ N := h ▸ mem_sup_left hb + obtain ⟨a, ha, n, hn, rfl⟩ := mem_sup.1 this + have hnB : n ∈ B := by + have := sub_mem hb (hAB ha); simpa using this + exact add_mem ha (hBN ⟨hnB, hn⟩) + +/-- The (U ⊓ N)-component test: if B ≤ U, x ∈ U ⊓ (B ⊔ N), π vanishes on B and is injective on U ⊓ N, +then x ∈ B ⟺ π x = 0. -/ +theorem mem_iff_proj {M' : Type*} [AddCommGroup M'] [Module K M'] (B N U : Submodule K M) + (π : M →ₗ[K] M') (hBU : B ≤ U) (hπB : ∀ b ∈ B, π b = 0) + (hπ : LinearMap.ker π ⊓ (U ⊓ N) = ⊥) (x : M) (hxU : x ∈ U) (hx : x ∈ B ⊔ N) : + x ∈ B ↔ π x = 0 := by + refine ⟨hπB x, fun h0 => ?_⟩ + obtain ⟨b, hb, n, hn, rfl⟩ := mem_sup.1 hx + have hnU : n ∈ U := by + have := sub_mem hxU (hBU hb); simpa using this + have hπn : π n = 0 := by rw [map_add, hπB b hb, zero_add] at h0; exact h0 + have : n ∈ LinearMap.ker π ⊓ (U ⊓ N) := ⟨hπn, hnU, hn⟩ + rw [hπ, mem_bot] at this + subst this; simpa using hb + +end Lat + +section Run +variable {K Reg C : Type*} [Field K] [Fintype Reg] [DecidableEq Reg] [DecidableEq C] +variable (z V : C) + +/-- With no loss (and the RankLaw hypotheses), A ⊔ N = B ⊔ N. -/ +theorem sup_eq_of_noloss (s : St K Reg C) (T : Finset Reg) (evs : List (Ev K Reg C)) + (hL : Legal z V s evs) (hN : ∀ e ∈ evs, NZ e) (hG : Good s T) (hS : Sp s = TS T) + (Rf : Reg → Reg → K) (G1 : Finset Reg) + (hNon : ∀ r ∉ G1, (run s evs).row r = Rf r) + (hTgt : span K (Set.range Rf) = TS (tokRun T evs)) (hl : ¬ Loss s evs) : + span K ((run s evs).row '' (G1 : Set Reg)) ⊔ span K (Rf '' (G1 : Set Reg)ᶜ) = + span K (Rf '' (G1 : Set Reg)) ⊔ span K (Rf '' (G1 : Set Reg)ᶜ) := by + set X := (run s evs).row with hXdef + have hNim : X '' (G1 : Set Reg)ᶜ = Rf '' (G1 : Set Reg)ᶜ := + Set.image_congr (fun r hr => hNon r (by simpa using hr)) + have hfull := span_run z V s T evs hL hN hG hS hl + rw [← hNim, ← span_range_split X G1, hNim, ← span_range_split Rf G1, hTgt]; exact hfull + +/-- **RankLaw, general form (no U).** Same hypotheses as `RankLaw.rank_law` minus `hRU`/`hUN`. +B = span V targets, N = span non-V targets, A = span V-ender end rows. -/ +theorem rank_law_gen (s : St K Reg C) (T : Finset Reg) (evs : List (Ev K Reg C)) + (hL : Legal z V s evs) (hN : ∀ e ∈ evs, NZ e) (hG : Good s T) (hS : Sp s = TS T) + (Rf : Reg → Reg → K) (G1 : Finset Reg) + (hNon : ∀ r ∉ G1, (run s evs).row r = Rf r) + (hTgt : span K (Set.range Rf) = TS (tokRun T evs)) : + VMix (run s evs).row Rf G1 ↔ ¬ Loss s evs ∧ + (∀ g ∈ G1, (run s evs).row g ∈ span K (Rf '' (G1 : Set Reg))) ∧ + span K (Rf '' (G1 : Set Reg)) ⊓ span K (Rf '' (G1 : Set Reg)ᶜ) ≤ + span K ((run s evs).row '' (G1 : Set Reg)) := by + set X := (run s evs).row with hXdef + have hNim : X '' (G1 : Set Reg)ᶜ = Rf '' (G1 : Set Reg)ᶜ := + Set.image_congr (fun r hr => hNon r (by simpa using hr)) + unfold VMix + rw [vmixM_iff_span, range_restrict, range_restrict] + have hAle : (∀ g ∈ G1, X g ∈ span K (Rf '' (G1 : Set Reg))) ↔ + span K (X '' (G1 : Set Reg)) ≤ span K (Rf '' (G1 : Set Reg)) := + ⟨fun h => span_le.2 (by rintro _ ⟨g, hg, rfl⟩; exact h g hg), + fun h g hg => h (subset_span ⟨g, hg, rfl⟩)⟩ + constructor + · intro hAB + have hfull : Sp (run s evs) = TS (tokRun T evs) := by + rw [← hTgt, Sp, ← hXdef, span_range_split X G1, span_range_split Rf G1, hAB, hNim] + refine ⟨(full_rank_iff_noloss z V s T evs hL hN hG hS).1 hfull, hAle.2 hAB.le, ?_⟩ + rw [hAB]; exact inf_le_left + · rintro ⟨hl, hB, hBN⟩ + have hsum := sup_eq_of_noloss z V s T evs hL hN hG hS Rf G1 hNon hTgt hl + exact (eq_iff_of_sup_eq _ _ _ hsum).2 ⟨hAle.1 hB, hBN⟩ + +/-- **Corrected condition (ii) relative to an arbitrary U ⊇ V targets.** π is any linear map that +vanishes on the V targets and is injective on U ⊓ N (it reads the "(U ⊓ N)-component"). -/ +theorem rank_law_proj {M' : Type*} [AddCommGroup M'] [Module K M'] + (s : St K Reg C) (T : Finset Reg) (evs : List (Ev K Reg C)) + (hL : Legal z V s evs) (hN : ∀ e ∈ evs, NZ e) (hG : Good s T) (hS : Sp s = TS T) + (Rf : Reg → Reg → K) (G1 : Finset Reg) (U : Submodule K (Reg → K)) (π : (Reg → K) →ₗ[K] M') + (hNon : ∀ r ∉ G1, (run s evs).row r = Rf r) + (hTgt : span K (Set.range Rf) = TS (tokRun T evs)) + (hRU : ∀ g ∈ G1, Rf g ∈ U) (hπR : ∀ g ∈ G1, π (Rf g) = 0) + (hπ : LinearMap.ker π ⊓ (U ⊓ span K (Rf '' (G1 : Set Reg)ᶜ)) = ⊥) : + VMix (run s evs).row Rf G1 ↔ ¬ Loss s evs ∧ + (∀ g ∈ G1, (run s evs).row g ∈ U ∧ π ((run s evs).row g) = 0) ∧ + span K (Rf '' (G1 : Set Reg)) ⊓ span K (Rf '' (G1 : Set Reg)ᶜ) ≤ + span K ((run s evs).row '' (G1 : Set Reg)) := by + set B := span K (Rf '' (G1 : Set Reg)) + have hBU : B ≤ U := span_le.2 (by rintro _ ⟨g, hg, rfl⟩; exact hRU g hg) + have hπB : ∀ b ∈ B, π b = 0 := by + intro b hb + have : B ≤ LinearMap.ker π := span_le.2 (by rintro _ ⟨g, hg, rfl⟩; exact hπR g hg) + exact this hb + rw [rank_law_gen z V s T evs hL hN hG hS Rf G1 hNon hTgt] + constructor + · rintro ⟨hl, hB, h3⟩ + exact ⟨hl, fun g hg => ⟨hBU (hB g hg), hπB _ (hB g hg)⟩, h3⟩ + · rintro ⟨hl, hU, h3⟩ + have hsum := sup_eq_of_noloss z V s T evs hL hN hG hS Rf G1 hNon hTgt hl + refine ⟨hl, fun g hg => ?_, h3⟩ + have hx : (run s evs).row g ∈ B ⊔ span K (Rf '' (G1 : Set Reg)ᶜ) := + hsum ▸ mem_sup_left (subset_span ⟨g, hg, rfl⟩) + exact (mem_iff_proj B _ U π hBU hπB hπ _ (hU g hg).1 hx).2 (hU g hg).2 + +/-- Independent targets (B ⊓ N = ⊥; true on #7623, whose 1501 public target rows have rank 1501): +the third clause is vacuous, and (ii) is "every V-ender row lies in the span of the V targets". -/ +theorem rank_law_indep (s : St K Reg C) (T : Finset Reg) (evs : List (Ev K Reg C)) + (hL : Legal z V s evs) (hN : ∀ e ∈ evs, NZ e) (hG : Good s T) (hS : Sp s = TS T) + (Rf : Reg → Reg → K) (G1 : Finset Reg) + (hNon : ∀ r ∉ G1, (run s evs).row r = Rf r) + (hTgt : span K (Set.range Rf) = TS (tokRun T evs)) + (hBN : span K (Rf '' (G1 : Set Reg)) ⊓ span K (Rf '' (G1 : Set Reg)ᶜ) = ⊥) : + VMix (run s evs).row Rf G1 ↔ ¬ Loss s evs ∧ + ∀ g ∈ G1, (run s evs).row g ∈ span K (Rf '' (G1 : Set Reg)) := by + rw [rank_law_gen z V s T evs hL hN hG hS Rf G1 hNon hTgt, hBN] + simp + +/-- Consistency: the original `rank_law` (U ⊓ N = ⊥) is `rank_law_proj` with π = 0. -/ +theorem rank_law_of_gen (s : St K Reg C) (T : Finset Reg) (evs : List (Ev K Reg C)) + (hL : Legal z V s evs) (hN : ∀ e ∈ evs, NZ e) (hG : Good s T) (hS : Sp s = TS T) + (Rf : Reg → Reg → K) (G1 : Finset Reg) (U : Submodule K (Reg → K)) + (hNon : ∀ r ∉ G1, (run s evs).row r = Rf r) + (hTgt : span K (Set.range Rf) = TS (tokRun T evs)) + (hRU : ∀ g ∈ G1, Rf g ∈ U) + (hUN : U ⊓ span K (Rf '' (G1 : Set Reg)ᶜ) = ⊥) : + VMix (run s evs).row Rf G1 ↔ ¬ Loss s evs ∧ ∀ g ∈ G1, (run s evs).row g ∈ U := by + have hBU : span K (Rf '' (G1 : Set Reg)) ≤ U := + span_le.2 (by rintro _ ⟨g, hg, rfl⟩; exact hRU g hg) + have hBN : span K (Rf '' (G1 : Set Reg)) ⊓ span K (Rf '' (G1 : Set Reg)ᶜ) = ⊥ := + eq_bot_iff.2 (fun x hx => hUN ▸ ⟨hBU hx.1, hx.2⟩) + rw [rank_law_proj (M' := K) z V s T evs hL hN hG hS Rf G1 U 0 hNon hTgt hRU (by simp) + (by simp [hUN]), hBN] + simp + +end Run +end RankLawC diff --git a/research/p104-tiered-ceiling/lean/Nov15/RankLawC.md b/research/p104-tiered-ceiling/lean/Nov15/RankLawC.md new file mode 100644 index 0000000000..8559526b12 --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/RankLawC.md @@ -0,0 +1,30 @@ +# RankLawC.lean: RankLaw condition (ii) when U meets span(non-V targets). No sorry, ~15 s, < 2.2 GB RSS +Imports the RankLaw olean (header has the build chain). Axioms: [propext, Classical.choice, Quot.sound]. + +Notation (end rows of the run with the V-hub ops deleted): +- X = those end rows; +- A = span X[G1]; +- B = span of the V targets Rf[G1]; +- N = span of the non-V targets. + +Hypotheses are those of `RankLaw.rank_law` (legal, NZ, Good, token span, hNon, hTgt), with no hUN. + +- `eq_iff_of_sup_eq`: if A ⊔ N = B ⊔ N, then A = B ⟺ A ≤ B ∧ B ⊓ N ≤ A. +- `rank_law_gen` (no U at all): V mix ⟺ (i) no lossy CLEAR/COPY ∧ (ii) every X g ∈ B ∧ (iii) B ⊓ N ≤ A. +- **`rank_law_proj` (the corrected (ii) for any U ⊇ B).** Let π be any linear map with π = 0 on the V targets and ker π ⊓ (U ⊓ N) = ⊥ (π reads the (U ⊓ N)-component). + Then V mix ⟺ (i) ∧ (ii') every X g ∈ U **and π(X g) = 0** ∧ (iii). + - So "zero W0 part" must be strengthened to "zero W0 part and zero (U ⊓ N)-component". +- `rank_law_indep`: if B ⊓ N = ⊥, (iii) is vacuous and (ii) reads "X g ∈ span V targets". + - This holds on #7623: the 1501 public target rows have rank 1501 (CopyCheck.md), and owned targets are 0. +- `rank_law_of_gen`: the original `rank_law` is `rank_law_proj` with π = 0. + - When U ⊓ N = ⊥, (iii) is automatic because B ⊓ N ≤ U ⊓ N = ⊥. + +Hand examples (why each extra clause is needed): +- **(ii').** RankLaw finding 2: G1 = {g}, N = {n}, Rf g = e1, Rf n = e2, U = everything, X g = e1 + e2. + - Here X g ∈ U but π(X g) ≠ 0 for π = e2-coordinate, and there is no V mix. +- **(iii).** One token e1; Rf g = Rf n = e1; X n = e1, X g = 0; empty run, so no loss. + - X g ∈ B, but A = 0 ≠ B. + - Only possible with dependent targets. + +**Finding.** RankLaw's prose "(ii) zero W0 part" is false when U ⊓ N ≠ 0, which is the natural case U = T_X + tokens: helper tokens e_h are non-V targets. +- Minimal fix: "(ii) every V-ender row is in U and has zero (U ⊓ N)-component"; with dependent targets, add (iii). diff --git a/research/p104-tiered-ceiling/lean/Nov15/RelaySandwich.lean b/research/p104-tiered-ceiling/lean/Nov15/RelaySandwich.lean new file mode 100644 index 0000000000..e3ad3667c8 --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/RelaySandwich.lean @@ -0,0 +1,157 @@ +/- +RELAY-SANDWICH law (NEWNATIVE R4 sec 3), See RelaySandwich.md. +Abstract: charts form a lattice; resident i of a relay chart c arrives from chart p i and departs to n i +(p i ≤ c ≤ n i, public steps ascend). Pinned: c = ⨆ p = ⨅ n. Then any chart c' that keeps every +resident's route ascending equals c. Bridge to FrameSep.Route (frames = submodules) included. +Also the cost identity for a 0 -> e helper with k evenly spaced stops: e * ln (k+1) (e = 9: 9 ln (k+1)). +-/ +import Nov15.FrameSep +import Nov15.JunkLB2 + +namespace RelaySandwich + +section Lattice +variable {L ι : Type*} [CompleteLattice L] + +/-- c is pinned by residents with arrival charts p and departure charts n. -/ +structure Pinned (p n : ι → L) (c : L) : Prop where + arrive : ∀ i, p i ≤ c + depart : ∀ i, c ≤ n i + join : c = ⨆ i, p i + meet : c = ⨅ i, n i + +/-- Admissible replacement of the stop: every resident's route stays ascending through c'. -/ +def Admissible (p n : ι → L) (c' : L) : Prop := ∀ i, p i ≤ c' ∧ c' ≤ n i + +/-- **RELAY-SANDWICH**: the only admissible stop chart is c itself. -/ +theorem admissible_unique {p n : ι → L} {c : L} (h : Pinned p n c) {c' : L} + (hc : Admissible p n c') : c' = c := by + apply le_antisymm + · rw [h.meet]; exact le_iInf fun i => (hc i).2 + · rw [h.join]; exact iSup_le fun i => (hc i).1 + +theorem admissible_iff {p n : ι → L} {c : L} (h : Pinned p n c) (c' : L) : + Admissible p n c' ↔ c' = c := + ⟨admissible_unique h, fun e => e ▸ fun i => ⟨h.arrive i, h.depart i⟩⟩ + +/-- Collapse onto a neighbour chart (some resident's previous or next chart d) is impossible +when no neighbour chart equals c. -/ +theorem no_neighbour_collapse {p n : ι → L} {c : L} (h : Pinned p n c) + (hp : ∀ i, p i ≠ c) (hn : ∀ i, n i ≠ c) (j : ι) : + ¬ Admissible p n (p j) ∧ ¬ Admissible p n (n j) := + ⟨fun a => hp j (admissible_unique h a), fun a => hn j (admissible_unique h a)⟩ + +/-- Non-degenerate pinned relay needs two residents (indeed no single resident's chart is c). -/ +theorem pinned_nontrivial {p n : ι → L} {c : L} (h : Pinned p n c) + (hp : ∀ i, p i ≠ c) [Nonempty ι] : ¬ Subsingleton ι := by + intro hs + obtain ⟨i⟩ := ‹Nonempty ι› + apply hp i + rw [h.join] + apply le_antisymm + · exact le_iSup p i + · exact iSup_le fun j => by rw [Subsingleton.elim j i] + +/-- The non-equality hypotheses are not redundant (degenerate resident with p = n = c): the +"neighbour" chart p 0 is admissible, but it equals c, so nothing is collapsed. -/ +example : ∃ (p n : Fin 1 → Prop) (c : Prop), Pinned p n c ∧ Admissible p n (p 0) ∧ p 0 = c := + ⟨fun _ => False, fun _ => False, False, + ⟨fun _ => le_rfl, fun _ => le_rfl, by simp, by simp⟩, fun _ => ⟨le_rfl, le_rfl⟩, rfl⟩ + +end Lattice + +section Route +open FrameSep +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] + +/-- Replace the frame at time t+1 by c'. -/ +def restop (R : Route K V) (t : ℕ) (c' : Submodule K V) : ℕ → Submodule K V := + Function.update R.f (t + 1) c' + +/-- If steps t and t+1 are public, the stop-replaced frame sequence has every step ascending +iff c' sits between the frames at t and t+2 (the route-ordering side of a collapse). -/ +theorem restop_valid_iff (R : Route K V) (t : ℕ) (h0 : ¬ R.owned t) (h1 : ¬ R.owned (t + 1)) + (c' : Submodule K V) : + (∀ s, ¬ R.owned s → restop R t c' s ≤ restop R t c' (s + 1)) ↔ + (R.f t ≤ c' ∧ c' ≤ R.f (t + 2)) := by + constructor + · intro h + have a := h t h0 + have b := h (t + 1) h1 + simp only [restop, Function.update_self, Function.update_of_ne (show t ≠ t + 1 by omega), + Function.update_of_ne (show t + 2 ≠ t + 1 by omega)] at a b + exact ⟨a, b⟩ + · rintro ⟨a, b⟩ s hs + by_cases e1 : s = t + · subst e1; simpa [restop] using a + by_cases e2 : s = t + 1 + · subst e2; simpa [restop] using b + have n1 : s ≠ t + 1 := e2 + have n2 : s + 1 ≠ t + 1 := fun h => e1 (by omega) + simpa [restop, Function.update_of_ne n1, Function.update_of_ne n2] using R.pub s hs + +/-- **Frame form.** Residents i with routes R i, each with public steps t i, t i + 1 and +frame c at time t i + 1; pinned by their frames at t i and t i + 2. If every resident's +stop-replaced route (stop chart c') is valid, c' = c. -/ +theorem route_collapse {ι : Type*} (R : ι → Route K V) (t : ι → ℕ) + (h0 : ∀ i, ¬ (R i).owned (t i)) (h1 : ∀ i, ¬ (R i).owned (t i + 1)) + {c : Submodule K V} + (hp : Pinned (fun i => (R i).f (t i)) (fun i => (R i).f (t i + 2)) c) + {c' : Submodule K V} + (hv : ∀ i, ∀ s, ¬ (R i).owned s → restop (R i) (t i) c' s ≤ restop (R i) (t i) c' (s + 1)) : + c' = c := + admissible_unique hp fun i => (restop_valid_iff (R i) (t i) (h0 i) (h1 i) c').1 (hv i) + +end Route + +section Cost +open JunkLB2 + +/-- Cost of a helper going 0 -> e in k+1 equal moves (k stops), per-stay accounting: +D0 = f(e) - Σ f(gap) over the k+1 moves. -/ +noncomputable def stopCost (f : ℝ → ℝ) (e : ℝ) (k : ℕ) : ℝ := + f e - ((List.replicate (k + 1) (f (e / (k + 1)))).sum) + +theorem stopCost_eq (f : ℝ → ℝ) (e : ℝ) (k : ℕ) : + stopCost f e k = f e - (k + 1) * f (e / (k + 1)) := by + simp [stopCost, List.sum_replicate, nsmul_eq_mul] + +/-- For f(r) = r ln r the cost is e ln (k+1). -/ +theorem stopCost_fL (e : ℝ) (k : ℕ) : stopCost fL e k = e * Real.log (k + 1) := by + have hk : (0 : ℝ) < (k : ℝ) + 1 := by positivity + rw [stopCost_eq] + unfold fL + by_cases he : e = 0 + · simp [he] + have hd : e / ((k : ℝ) + 1) ≠ 0 := div_ne_zero he hk.ne' + rw [Real.log_div he hk.ne'] + field_simp + ring + +/-- The 0 -> 9 helper: 9 ln (k+1). -/ +theorem stopCost_nine (k : ℕ) : stopCost fL 9 k = 9 * Real.log (k + 1) := stopCost_fL 9 k + +/-- Integer-gap cases (gap 9/(k+1) integral): k = 0, 2, 8 give 0, 9 ln 3, 9 ln 9 = 18 ln 3. -/ +theorem stopCost_k2 : stopCost fL 9 2 = 9 * Real.log 3 := by + rw [stopCost_nine]; norm_num + +/-- Stops are paid: cost is strictly increasing in k (convexity not needed for f = r ln r). -/ +theorem stopCost_strictMono {k m : ℕ} (h : k < m) : stopCost fL 9 k < stopCost fL 9 m := by + rw [stopCost_nine, stopCost_nine] + have : Real.log ((k : ℝ) + 1) < Real.log ((m : ℝ) + 1) := + Real.log_lt_log (by positivity) (by exact_mod_cast Nat.add_lt_add_right h 1) + linarith + +end Cost + +#print axioms admissible_unique +#print axioms no_neighbour_collapse +#print axioms pinned_nontrivial +#print axioms restop_valid_iff +#print axioms route_collapse +#print axioms stopCost_fL +#print axioms stopCost_nine +#print axioms stopCost_k2 +#print axioms stopCost_strictMono + +end RelaySandwich diff --git a/research/p104-tiered-ceiling/lean/Nov15/RelaySandwich.md b/research/p104-tiered-ceiling/lean/Nov15/RelaySandwich.md new file mode 100644 index 0000000000..ecd7b9337e --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/RelaySandwich.md @@ -0,0 +1,17 @@ +# RelaySandwich.lean: NEWNATIVE R4 LAW RELAY-SANDWICH + stop-cost identity +Imports Nov15.FrameSep, Nov15.JunkLB2. Kernel-only, 5 s / 2.3 GB, no sorry/native_decide; 9 `#print axioms` all within [propext, Classical.choice, Quot.sound] (the lattice theorems use none). +Build: FrameSep olean was missing; built with `runlean.sh Nov15/FrameSep.lean .lake/build/lib/lean/Nov15/FrameSep.olean`. + +## Results +- `Pinned p n c`: p i ≤ c ≤ n i, c = ⨆ p, c = ⨅ n (any complete lattice, any index type). +- `admissible_unique` / `admissible_iff`: a chart c' keeping every resident ascending (p i ≤ c' ≤ n i) equals c. So no stop can be moved or collapsed to another chart while all residents still meet there. +- `no_neighbour_collapse`: if no p i or n i equals c, no neighbour chart (p j or n j) is admissible. +- `pinned_nontrivial`: under p i ≠ c a pinned relay has at least 2 residents. +- `restop_valid_iff`, `route_collapse`: frame form on FrameSep.Route (submodules). Replacing the frame at t+1 by c' keeps all public steps ascending iff f t ≤ c' ≤ f (t+2); for residents pinned by those frames, c' = c. +- `stopCost_fL`: helper 0 -> e with k stops (k+1 equal moves), D0 = f(e) - Σ f(gap) = e ln(k+1) for f = r ln r; `stopCost_nine`: 9 ln(k+1). `stopCost_strictMono`: strictly increasing in k. k = 2 gives 9 ln 3 (integer gap 3). + +## Scope / statements checked +- R4's law is TRUE as written, with one reading made explicit: "collapse" means a chart change that keeps ALL residents at one common chart (they must meet to relay). If a single resident drops its stop it stops meeting the others; that is partner-changing re-routing, which R4 puts out of scope (its test (c)). +- The non-equality hypothesis is needed only to make neighbour charts distinct from c; uniqueness of an admissible chart holds without it (example in the file: degenerate p = n = c). +- Cost identity: "evenly spaced" gives integer dims only for (k+1) | 9 (k = 0, 2, 8). For other k the identity is the real-gap version (PRICEKIT charges |Δ dim| with integer dims, so it needs integer gaps). Per-stay form: this is FloorD0's chD0 = f(e - d0) - Σ f(|Δ|) specialised to equal gaps; I proved the closed form directly, not via the MChain machinery. +- Not formalised: that the 238/254 families in R4 (c) really satisfy Pinned (computational [C] fact). diff --git a/research/p104-tiered-ceiling/lean/Nov15/SwapNull.lean b/research/p104-tiered-ceiling/lean/Nov15/SwapNull.lean new file mode 100644 index 0000000000..c106f29bce --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/SwapNull.lean @@ -0,0 +1,732 @@ +/- +SwapNull, See SwapNull.md. +Formalises LAWBUILD M3's law SWAP-NULL (internal notes). + +Part A (op level, TokenCancel's model): the 4-op swap gadget + add h1 h2 (+1); add h2 h1 (-1); add h1 h2 (+1); scale h2 (-1) (3 ADD + SCALE -1, all at chart c) +exchanges the rows of h1 and h2. Tail swap = gadget, then every later event renamed h1<->h2: +the final state is the unswapped final state with the rows of h1, h2 exchanged (`tail_run`). +Head swap = earlier events renamed, then gadget: every final row has its h1/h2 COORDINATES +exchanged (`head_run`). +Part B (hub model, matrix level): only a V mix L (acts on V-ender rows) or a {0}-prefix M (acts on +G0 columns) can undo that; exact statements `tail_iff`, `head_iff`, `undo_one_iff`. +Part C (ladder): per-helper cost f(e-b) - sum f(gaps) (RelaySandwich.stopCost); the swap leaves the +stay multiset unchanged and changes the span terms by a rectangle difference, which is 0 iff the +ends agree or the births agree (`delta_eq`, `delta_zero_end`, `delta_zero_birth`). +Part D: law bundle and a concrete witness. +-/ +import Nov15.TokenCancel +import Nov15.RelaySandwich +import Nov15.SwapWord +import Mathlib.Data.Matrix.Mul +import Mathlib.LinearAlgebra.Matrix.ToLin + +set_option linter.unusedSectionVars false + +namespace SwapNull +open TokenCancel + +/-! ### Part A: the gadget and the two renamings -/ +section Op +variable {K Reg C : Type*} [Field K] [DecidableEq Reg] [DecidableEq C] + +/-- The 4-op swap gadget at chart `c`. -/ +def gadget (h1 h2 : Reg) (c : C) : List (Ev K Reg C) := + [.add h1 h2 1 c, .add h2 h1 (-1) c, .add h1 h2 1 c, .scale h2 (-1) c] + +theorem gadget_legal (h1 h2 : Reg) (hne : h1 ≠ h2) (c : C) (z V : C) (s : St K Reg C) + (a : s.loc h1 = some c) (b : s.loc h2 = some c) : + Legal z V s (gadget h1 h2 c) := by + simp [gadget, Legal, LegalEv, step, hne, hne.symm, a, b] + +/-- Rows and locations read through a register permutation. -/ +def permSt (σ : Equiv.Perm Reg) (s : St K Reg C) : St K Reg C := + ⟨fun r => s.row (σ r), fun r => s.loc (σ r)⟩ + +/-- Rows with their coordinates read through σ. -/ +def cpermSt (σ : Equiv.Perm Reg) (s : St K Reg C) : St K Reg C := + ⟨fun r => fun k => s.row r (σ k), s.loc⟩ + +def ren (σ : Equiv.Perm Reg) : Ev K Reg C → Ev K Reg C + | .born i c => .born (σ i) c + | .init i c => .init (σ i) c + | .move i c => .move (σ i) c + | .add i j a c => .add (σ i) (σ j) a c + | .scale i u c => .scale (σ i) u c + | .clear i c => .clear (σ i) c + | .copy i j c => .copy (σ i) (σ j) c + +theorem gadget_run (h1 h2 : Reg) (hne : h1 ≠ h2) (c : C) (s : St K Reg C) : + (run s (gadget h1 h2 c)).row = (fun r => s.row (Equiv.swap h1 h2 r)) ∧ + (run s (gadget h1 h2 c)).loc = s.loc := by + refine ⟨?_, ?_⟩ + · funext r + by_cases r1 : r = h1 + · subst r1 + simp [gadget, run, step, hne, hne.symm] + · by_cases r2 : r = h2 + · subst r2 + simp [gadget, run, step, hne, hne.symm, Function.update_apply] + · simp [gadget, run, step, r1, r2, Function.update_apply, Equiv.swap_apply_of_ne_of_ne] + · simp [gadget, run, step] + +lemma upd_perm {β : Type*} (σ : Equiv.Perm Reg) (hσ : ∀ r, σ (σ r) = r) (f : Reg → β) + (i : Reg) (v : β) : + (fun r => Function.update f i v (σ r)) = Function.update (fun r => f (σ r)) (σ i) v := by + funext r + simp only [Function.update_apply] + have : σ r = i ↔ r = σ i := ⟨fun h => by rw [← h, hσ], fun h => by rw [h, hσ]⟩ + simp only [this] + +theorem step_permSt (σ : Equiv.Perm Reg) (hσ : ∀ r, σ (σ r) = r) (s : St K Reg C) + (e : Ev K Reg C) (hb : ∀ i c, e = .born i c → σ i = i) : + step (permSt σ s) (ren σ e) = permSt σ (step s e) := by + cases e with + | born i c => + have hi := hb i c rfl + simp only [step, ren, permSt, St.mk.injEq] + rw [upd_perm σ hσ, upd_perm σ hσ, hi] + simp + | init i c => + simp only [step, ren, permSt, St.mk.injEq] + rw [upd_perm σ hσ, upd_perm σ hσ] + simp + | move i c => + simp only [step, ren, permSt, St.mk.injEq] + rw [upd_perm σ hσ] + simp + | add i j a c => + simp only [step, ren, permSt, St.mk.injEq] + rw [upd_perm σ hσ] + simp [hσ] + | scale i u c => + simp only [step, ren, permSt, St.mk.injEq] + rw [upd_perm σ hσ] + simp [hσ] + | clear i c => + simp only [step, ren, permSt, St.mk.injEq] + rw [upd_perm σ hσ] + simp + | copy i j a => + simp only [step, ren, permSt, St.mk.injEq] + rw [upd_perm σ hσ] + simp [hσ] + +theorem run_permSt (σ : Equiv.Perm Reg) (hσ : ∀ r, σ (σ r) = r) (evs : List (Ev K Reg C)) + (hb : ∀ e ∈ evs, ∀ i c, e = .born i c → σ i = i) (s : St K Reg C) : + run (permSt σ s) (evs.map (ren σ)) = permSt σ (run s evs) := by + induction evs generalizing s with + | nil => rfl + | cons e es ih => + simp only [List.map_cons, run] + rw [step_permSt σ hσ s e (hb e (by simp)), ih (fun e' he' => hb e' (by simp [he']))] + +/-- Tail swap: gadget at the shared chart, then every later event renamed h1 <-> h2. +Final rows = unswapped final rows with h1, h2 exchanged; locations unchanged. -/ +theorem tail_run (h1 h2 : Reg) (hne : h1 ≠ h2) (c : C) (s : St K Reg C) + (a : s.loc h1 = some c) (b : s.loc h2 = some c) (evs : List (Ev K Reg C)) + (hb : ∀ e ∈ evs, ∀ i c, e = .born i c → i ≠ h1 ∧ i ≠ h2) : + run s (gadget h1 h2 c ++ evs.map (ren (Equiv.swap h1 h2))) = + permSt (Equiv.swap h1 h2) (run s evs) := by + have hσ : ∀ r, Equiv.swap h1 h2 (Equiv.swap h1 h2 r) = r := fun r => Equiv.swap_apply_self _ _ _ + have hg := gadget_run h1 h2 hne c s + have hs : run s (gadget h1 h2 c) = permSt (Equiv.swap h1 h2) s := by + have hloc : ∀ r, s.loc (Equiv.swap h1 h2 r) = s.loc r := by + intro r + by_cases r1 : r = h1 + · subst r1; simp [a, b] + · by_cases r2 : r = h2 + · subst r2; simp [a, b] + · rw [Equiv.swap_apply_of_ne_of_ne r1 r2] + cases hr : run s (gadget h1 h2 c) with + | mk row loc => + rw [hr] at hg + simp only [permSt, St.mk.injEq] + obtain ⟨hg1, hg2⟩ := hg + simp only at hg1 hg2 + refine ⟨hg1, ?_⟩ + rw [hg2]; funext r; exact (hloc r).symm + rw [SwapWord.run_append, hs] + exact run_permSt _ hσ evs (fun e he i c h => by + obtain ⟨x, y⟩ := hb e he i c h + exact Equiv.swap_apply_of_ne_of_ne x y) s + +/-- Registers and coordinates both read through σ (the state of a run whose events were renamed). -/ +def bothSt (σ : Equiv.Perm Reg) (s : St K Reg C) : St K Reg C := + ⟨fun r k => s.row (σ r) (σ k), fun r => s.loc (σ r)⟩ + +lemma upd_both (σ : Equiv.Perm Reg) (hσ : ∀ r, σ (σ r) = r) (f : Reg → Reg → K) + (i : Reg) (v : Reg → K) : + (fun r k => Function.update f i v (σ r) (σ k)) = + Function.update (fun r k => f (σ r) (σ k)) (σ i) (fun k => v (σ k)) := by + funext r k + have : σ r = i ↔ r = σ i := ⟨fun h => by rw [← h, hσ], fun h => by rw [h, hσ]⟩ + by_cases h : r = σ i + · subst h + simp [Function.update_apply, hσ] + · have h' : ¬ σ r = i := fun x => h (this.1 x) + simp [Function.update_apply, h, h'] + +theorem step_bothSt (σ : Equiv.Perm Reg) (hσ : ∀ r, σ (σ r) = r) (s : St K Reg C) + (e : Ev K Reg C) : + step (bothSt σ s) (ren σ e) = bothSt σ (step s e) := by + cases e with + | born i c => + simp only [step, ren, bothSt, St.mk.injEq] + rw [upd_both σ hσ, upd_perm σ hσ] + have : (fun k => (Pi.single i (1 : K) : Reg → K) (σ k)) = Pi.single (σ i) 1 := by + funext k + have : σ k = i ↔ k = σ i := ⟨fun h => by rw [← h, hσ], fun h => by rw [h, hσ]⟩ + by_cases h : k = σ i + · simp [Pi.single_apply, h, this.2 h, hσ] + · have hn : ¬ σ k = i := fun x => h (this.1 x) + simp [Pi.single_apply, h, hn] + rw [this]; simp + | init i c => + simp only [step, ren, bothSt, St.mk.injEq] + rw [upd_both σ hσ, upd_perm σ hσ]; simp; congr 1 + | move i c => + simp only [step, ren, bothSt, St.mk.injEq] + rw [upd_perm σ hσ]; simp + | add i j a c => + simp only [step, ren, bothSt, St.mk.injEq] + rw [upd_both σ hσ]; simp [hσ]; congr 1 + | scale i u c => + simp only [step, ren, bothSt, St.mk.injEq] + rw [upd_both σ hσ]; simp [hσ]; congr 1 + | clear i c => + simp only [step, ren, bothSt, St.mk.injEq] + rw [upd_both σ hσ]; simp; congr 1 + | copy i j c => + simp only [step, ren, bothSt, St.mk.injEq] + rw [upd_both σ hσ]; simp [hσ] + +theorem run_bothSt (σ : Equiv.Perm Reg) (hσ : ∀ r, σ (σ r) = r) (evs : List (Ev K Reg C)) + (s : St K Reg C) : + run (bothSt σ s) (evs.map (ren σ)) = bothSt σ (run s evs) := by + induction evs generalizing s with + | nil => rfl + | cons e es ih => + simp only [List.map_cons, run] + rw [step_bothSt σ hσ s e, ih] + +theorem step_cpermSt (σ : Equiv.Perm Reg) (s : St K Reg C) + (e : Ev K Reg C) (hσ : ∀ r, σ (σ r) = r) (hb : ∀ i c, e = .born i c → σ i = i) : + step (cpermSt σ s) e = cpermSt σ (step s e) := by + cases e with + | born i c => + have hi := hb i c rfl + simp only [step, cpermSt] + congr 1 + funext r k + by_cases h : r = i + · subst h + have : σ k = r ↔ k = r := ⟨fun h => by rw [← hi, ← h, hσ], fun h => by rw [h, hi]⟩ + by_cases hk : k = r + · simp [Pi.single_apply, hk, hi] + · have hn : ¬ σ k = r := fun x => hk (this.1 x) + simp [Pi.single_apply, hk, hn] + · simp [Function.update_apply, h] + | init i c => + simp only [step, cpermSt] + congr 1 + funext r k; by_cases h : r = i <;> simp [Function.update_apply, h] + | move i c => simp [step, cpermSt] + | add i j a c => + simp only [step, cpermSt] + congr 1 + funext r k; by_cases h : r = i <;> simp [Function.update_apply, h] + | scale i u c => + simp only [step, cpermSt] + congr 1 + funext r k; by_cases h : r = i <;> simp [Function.update_apply, h] + | clear i c => + simp only [step, cpermSt] + congr 1 + funext r k; by_cases h : r = i <;> simp [Function.update_apply, h] + | copy i j c => + simp only [step, cpermSt] + congr 1 + funext r k; by_cases h : r = i <;> simp [Function.update_apply, h] + +theorem run_cpermSt (σ : Equiv.Perm Reg) (hσ : ∀ r, σ (σ r) = r) (evs : List (Ev K Reg C)) + (hb : ∀ e ∈ evs, ∀ i c, e = .born i c → σ i = i) (s : St K Reg C) : + run (cpermSt σ s) evs = cpermSt σ (run s evs) := by + induction evs generalizing s with + | nil => rfl + | cons e es ih => + simp only [run] + rw [step_cpermSt σ s e hσ (hb e (by simp)), ih (fun e' he' => hb e' (by simp [he']))] + +/-- Head swap: earlier events (`pre`) renamed h1 <-> h2, then the gadget at the shared chart, then the +original later events (`post`, no births of h1, h2). If the start state is σ-symmetric, every +final row has its h1/h2 coordinates exchanged; locations are unchanged. -/ +theorem head_run (h1 h2 : Reg) (hne : h1 ≠ h2) (c : C) (s0 : St K Reg C) + (hs0 : bothSt (Equiv.swap h1 h2) s0 = s0) + (pre post : List (Ev K Reg C)) + (a : (run s0 pre).loc h1 = some c) (b : (run s0 pre).loc h2 = some c) + (hb : ∀ e ∈ post, ∀ i c, e = .born i c → i ≠ h1 ∧ i ≠ h2) : + run s0 (pre.map (ren (Equiv.swap h1 h2)) ++ gadget h1 h2 c ++ post) = + cpermSt (Equiv.swap h1 h2) (run s0 (pre ++ post)) := by + have hσ : ∀ r, Equiv.swap h1 h2 (Equiv.swap h1 h2 r) = r := fun r => Equiv.swap_apply_self _ _ _ + set σ := Equiv.swap h1 h2 with hσdef + set t := run s0 pre with ht + have h1' : run s0 (pre.map (ren σ)) = bothSt σ t := by + conv_lhs => rw [← hs0] + exact run_bothSt σ hσ pre s0 + have hg := gadget_run h1 h2 hne c (bothSt σ t) + have hloc : ∀ r, t.loc (σ r) = t.loc r := by + intro r + by_cases r1 : r = h1 + · subst r1; simp [σ, a, b] + · by_cases r2 : r = h2 + · subst r2; simp [σ, a, b] + · rw [Equiv.swap_apply_of_ne_of_ne r1 r2] + have hs : run (bothSt σ t) (gadget h1 h2 c) = cpermSt σ t := by + cases hr : run (bothSt σ t) (gadget h1 h2 c) with + | mk row loc => + rw [hr] at hg + obtain ⟨hg1, hg2⟩ := hg + simp only [bothSt] at hg1 hg2 + simp only [cpermSt, St.mk.injEq] + refine ⟨?_, ?_⟩ + · rw [hg1]; funext r k; exact congrArg (fun x => t.row x (σ k)) (hσ r) + · rw [hg2]; funext r; exact hloc r + rw [SwapWord.run_append, SwapWord.run_append, h1', hs, + run_cpermSt σ hσ post (fun e he i c h => by + obtain ⟨x, y⟩ := hb e he i c h + exact Equiv.swap_apply_of_ne_of_ne x y), SwapWord.run_append s0 pre post] + +end Op + +/-! ### Part B: what the hubs can undo (matrix level; HubSettle's V mix and {0}-prefix) -/ +section Hub +variable {K Reg : Type*} [Field K] [Fintype Reg] [DecidableEq Reg] + +/-- `A` is the identity outside the `S × S` block (a hub op acts only inside its own block). -/ +def Blk (S : Reg → Prop) (A : Matrix Reg Reg K) : Prop := + ∀ i k, ¬ (S i ∧ S k) → A i k = (1 : Matrix Reg Reg K) i k + +/-- F' can be restored to F by a V mix `L` (block on V-enders, acts on rows) and a {0}-prefix `M` +(block on G0 columns, right multiplication). Invertibility is not demanded (strengthens the +only-if directions); the witnesses used for the if directions are permutation matrices. -/ +def Undo (V G0 : Reg → Prop) (F F' : Matrix Reg Reg K) : Prop := + ∃ L M : Matrix Reg Reg K, Blk V L ∧ Blk G0 M ∧ L * F' * M = F + +/-- Tail swap of the final matrix: rows h1,h2 exchanged. -/ +def rowSw (σ : Equiv.Perm Reg) (F : Matrix Reg Reg K) : Matrix Reg Reg K := + Matrix.of fun i k => F (σ i) k +/-- Head swap of the final matrix: coordinates h1,h2 exchanged. -/ +def colSw (σ : Equiv.Perm Reg) (F : Matrix Reg Reg K) : Matrix Reg Reg K := + Matrix.of fun i k => F i (σ k) + +def swapMat (σ : Equiv.Perm Reg) : Matrix Reg Reg K := + Matrix.of fun i k => if k = σ i then 1 else 0 + +lemma blk_one (S : Reg → Prop) : Blk S (1 : Matrix Reg Reg K) := fun _ _ _ => rfl + +lemma swapMat_mul (σ : Equiv.Perm Reg) (A : Matrix Reg Reg K) : swapMat σ * A = rowSw σ A := by + ext i k + simp [Matrix.mul_apply, swapMat, rowSw] + +lemma mul_swapMat (σ : Equiv.Perm Reg) (hσ : ∀ r, σ (σ r) = r) (A : Matrix Reg Reg K) : + A * swapMat σ = colSw σ A := by + ext i k + simp only [Matrix.mul_apply, swapMat, colSw, Matrix.of_apply] + have : ∀ j, (k = σ j) ↔ (j = σ k) := fun j => ⟨fun h => by rw [h, hσ], fun h => by rw [h, hσ]⟩ + simp [this] + +lemma swapMat_blk (h1 h2 : Reg) (S : Reg → Prop) (a : S h1) (b : S h2) : + Blk S (swapMat (Equiv.swap h1 h2) : Matrix Reg Reg K) := by + intro i k hik + simp only [swapMat, Matrix.of_apply, Matrix.one_apply] + have hk1 : ∀ x, S x → ¬ S k → x ≠ k := fun x hx hk h => hk (h ▸ hx) + by_cases i1 : i = h1 + · subst i1 + have hk : ¬ S k := fun h => hik ⟨a, h⟩ + simp [hk1 _ a hk, hk1 _ b hk, (hk1 _ a hk).symm, (hk1 _ b hk).symm] + · by_cases i2 : i = h2 + · subst i2 + have hk : ¬ S k := fun h => hik ⟨b, h⟩ + simp [hk1 _ a hk, hk1 _ b hk, (hk1 _ a hk).symm, (hk1 _ b hk).symm] + · rw [Equiv.swap_apply_of_ne_of_ne i1 i2] + simp [eq_comm] + +lemma blk_row {V : Reg → Prop} {L : Matrix Reg Reg K} (hL : Blk V L) {x : Reg} (hx : ¬ V x) + (Y : Matrix Reg Reg K) : (L * Y) x = Y x := by + funext k + have : ∀ m, L x m = if x = m then 1 else 0 := fun m => by + simpa [Matrix.one_apply] using hL x m (fun h => hx h.1) + simp [Matrix.mul_apply, this] + +lemma mul_blk_col {G0 : Reg → Prop} {M : Matrix Reg Reg K} (hM : Blk G0 M) {a : Reg} + (ha : ¬ G0 a) (Y : Matrix Reg Reg K) (i : Reg) : (Y * M) i a = Y i a := by + have : ∀ j, M j a = if j = a then 1 else 0 := fun j => by + simpa [Matrix.one_apply] using hM j a (fun h => ha h.2) + simp [Matrix.mul_apply, this] + +lemma row_eq {V : Reg → Prop} {F F' L M : Matrix Reg Reg K} (hL : Blk V L) + (h : L * F' * M = F) {x : Reg} (hx : ¬ V x) : (F' * M) x = F x := by + rw [Matrix.mul_assoc] at h + have := blk_row hL hx (F' * M) + rw [h] at this + exact this.symm + +section Swap +variable (h1 h2 : Reg) + +local notation "σ" => Equiv.swap h1 h2 + +lemma swap_inv (r : Reg) : σ (σ r) = r := Equiv.swap_apply_self _ _ _ + +/-- Both helpers end in V: the V mix undoes the tail swap. -/ +theorem tail_if (V G0 : Reg → Prop) (F : Matrix Reg Reg K) (a : V h1) (b : V h2) : + Undo V G0 F (rowSw σ F) := by + refine ⟨swapMat σ, 1, swapMat_blk h1 h2 V a b, blk_one _, ?_⟩ + rw [Matrix.mul_one, swapMat_mul] + ext i k + simp [rowSw, swap_inv] + +/-- Both helpers born in {0}: the {0}-prefix undoes the head swap. -/ +theorem head_if (V G0 : Reg → Prop) (F : Matrix Reg Reg K) (a : G0 h1) (b : G0 h2) : + Undo V G0 F (colSw σ F) := by + refine ⟨1, swapMat σ, blk_one _, swapMat_blk h1 h2 G0 a b, ?_⟩ + rw [Matrix.one_mul, mul_swapMat σ (swap_inv h1 h2)] + ext i k + simp [colSw, swap_inv] + +lemma ab_cases (a : Reg) (ha : a = h1 ∨ a = h2) (hne : h1 ≠ h2) : + (a = h1 ∧ σ a = h2) ∨ (a = h2 ∧ σ a = h1) := by + rcases ha with rfl | rfl + · left; simp + · right; simp + +/-- Tail swap, only-if. `hrig`: the unchanged non-V rows pin every {0}-prefix to the identity +(`rigid_of_span` gives this from a spanning condition). Then a tail swap is undone only if both +helpers end in V. -/ +theorem tail_only_if (V G0 : Reg → Prop) (hne : h1 ≠ h2) (F : Matrix Reg Reg K) + (hF1 : F h1 = Pi.single h1 1) (hF2 : F h2 = Pi.single h2 1) + (hrig : ∀ M : Matrix Reg Reg K, Blk G0 M → + (∀ x, x ≠ h1 → x ≠ h2 → ¬ V x → (F * M) x = F x) → M = 1) : + Undo V G0 F (rowSw σ F) → V h1 ∧ V h2 := by + rintro ⟨L, M, hL, hM, h⟩ + by_contra hn + obtain ⟨a, ha, haV⟩ : ∃ a, (a = h1 ∨ a = h2) ∧ ¬ V a := by + by_cases v1 : V h1 + · exact ⟨h2, Or.inr rfl, fun v2 => hn ⟨v1, v2⟩⟩ + · exact ⟨h1, Or.inl rfl, v1⟩ + have key : ∀ x, ¬ V x → (rowSw σ F * M) x = F x := fun x hx => row_eq hL h hx + have hM1 : M = 1 := by + refine hrig M hM (fun x hx1 hx2 hxV => ?_) + have := key x hxV + have hsx : σ x = x := Equiv.swap_apply_of_ne_of_ne hx1 hx2 + funext k + have := congrFun this k + simpa [rowSw, Matrix.mul_apply, hsx] using this + subst hM1 + have e : F (σ a) = F a := by + have := key a haV + rw [Matrix.mul_one] at this + exact this + rcases ab_cases h1 h2 a ha hne with ⟨rfl, h'⟩ | ⟨rfl, h'⟩ + · rw [h', hF1, hF2] at e + have := congrFun e a + simp [Pi.single_apply, hne.symm] at this + · rw [h', hF1, hF2] at e + have := congrFun e a + simp [Pi.single_apply, hne] at this + +/-- Head swap, only-if: if some non-V row distinguishes the h1 and h2 coordinates, the swap is +undone only if both helpers are born in {0}. -/ +theorem head_only_if (V G0 : Reg → Prop) (hne : h1 ≠ h2) (F : Matrix Reg Reg K) + (hw : ∃ x, ¬ V x ∧ F x h1 ≠ F x h2) : + Undo V G0 F (colSw σ F) → G0 h1 ∧ G0 h2 := by + rintro ⟨L, M, hL, hM, h⟩ + obtain ⟨x, hxV, hxne⟩ := hw + by_contra hn + obtain ⟨a, ha, haG⟩ : ∃ a, (a = h1 ∨ a = h2) ∧ ¬ G0 a := by + by_cases v1 : G0 h1 + · exact ⟨h2, Or.inr rfl, fun v2 => hn ⟨v1, v2⟩⟩ + · exact ⟨h1, Or.inl rfl, v1⟩ + have e := congrFun (row_eq hL h hxV) a + rw [mul_blk_col hM haG] at e + simp only [colSw, Matrix.of_apply] at e + rcases ab_cases h1 h2 a ha hne with ⟨rfl, h'⟩ | ⟨rfl, h'⟩ + · rw [h'] at e; exact hxne e.symm + · rw [h'] at e; exact hxne e + +/-- Identity-final case: the swap matrix is the same for both kinds; it is undone iff both +helpers end in V or both are born in {0}. -/ +theorem undo_one_iff (V G0 : Reg → Prop) (hne : h1 ≠ h2) : + Undo V G0 (1 : Matrix Reg Reg K) (rowSw σ 1) ↔ (V h1 ∧ V h2) ∨ (G0 h1 ∧ G0 h2) := by + constructor + · rintro ⟨L, M, hL, hM, h⟩ + by_cases hv : V h1 ∧ V h2 + · exact Or.inl hv + right + obtain ⟨a, ha, haV⟩ : ∃ a, (a = h1 ∨ a = h2) ∧ ¬ V a := by + by_cases v1 : V h1 + · exact ⟨h2, Or.inr rfl, fun v2 => hv ⟨v1, v2⟩⟩ + · exact ⟨h1, Or.inl rfl, v1⟩ + have e := congrFun (row_eq hL h haV) a + have hMa : M (σ a) a = 1 := by + have : (rowSw σ (1 : Matrix Reg Reg K) * M) a a = M (σ a) a := by + simp [rowSw, Matrix.mul_apply, Matrix.one_apply] + rw [this] at e + simpa using e + have hG : G0 (σ a) ∧ G0 a := by + by_contra hc + have := hM (σ a) a hc + rw [hMa] at this + have hn : σ a ≠ a := by + rcases ab_cases h1 h2 a ha hne with ⟨rfl, h'⟩ | ⟨rfl, h'⟩ + · rw [h']; exact hne.symm + · rw [h']; exact hne + simp [Matrix.one_apply, hn] at this + rcases ab_cases h1 h2 a ha hne with ⟨rfl, h'⟩ | ⟨rfl, h'⟩ + · rw [h'] at hG; exact ⟨hG.2, hG.1⟩ + · rw [h'] at hG; exact hG + · rintro (⟨a, b⟩ | ⟨a, b⟩) + · exact tail_if h1 h2 V G0 1 a b + · have := head_if h1 h2 V G0 (1 : Matrix Reg Reg K) a b + have e : colSw σ (1 : Matrix Reg Reg K) = rowSw σ 1 := by + ext i k + have : (σ i = k) ↔ (i = σ k) := + ⟨fun h => by rw [← h, swap_inv], fun h => by rw [h, swap_inv]⟩ + simp [colSw, rowSw, Matrix.one_apply, this] + rwa [e] at this + +end Swap + +end Hub + +section Rigid +variable {K Reg : Type*} [Field K] [Fintype Reg] [DecidableEq Reg] + +lemma single_vecMul (M : Matrix Reg Reg K) (i : Reg) : + Matrix.vecMul (Pi.single i (1 : K) : Reg → K) M = M i := by + funext j + simp [Matrix.vecMul, dotProduct, Pi.single_apply] + +/-- A spanning condition forces rigidity: if the (unchanged, non-V) rows of F together with the unit +vectors of the non-G0 coordinates span everything, then a G0-block prefix that fixes those rows is 1. -/ +theorem rigid_of_span (G0 : Reg → Prop) (T : Set Reg) (F : Matrix Reg Reg K) + (hspan : Submodule.span K ((fun x => F x) '' T ∪ + Set.range (fun k : {k // ¬ G0 k} => (Pi.single k.1 (1 : K) : Reg → K))) = ⊤) + (M : Matrix Reg Reg K) (hM : Blk G0 M) (hfix : ∀ x ∈ T, (F * M) x = F x) : M = 1 := by + let φ : (Reg → K) →ₗ[K] (Reg → K) := Matrix.vecMulLinear M - LinearMap.id + have hle : Submodule.span K ((fun x => F x) '' T ∪ + Set.range (fun k : {k // ¬ G0 k} => (Pi.single k.1 (1 : K) : Reg → K))) ≤ + LinearMap.ker φ := by + rw [Submodule.span_le] + rintro v (⟨x, hx, rfl⟩ | ⟨k, rfl⟩) + · have := hfix x hx + simp only [SetLike.mem_coe, LinearMap.mem_ker, φ, LinearMap.sub_apply, + Matrix.vecMulLinear_apply, LinearMap.id_apply, sub_eq_zero] + funext j + have := congrFun this j + simpa [Matrix.mul_apply, Matrix.vecMul, dotProduct] using this + · simp only [SetLike.mem_coe, LinearMap.mem_ker, φ, LinearMap.sub_apply, + Matrix.vecMulLinear_apply, LinearMap.id_apply, sub_eq_zero] + rw [single_vecMul] + funext j + have := hM k.1 j (fun h => k.2 h.1) + simp only [Matrix.one_apply] at this + rw [this] + simp [Pi.single_apply, eq_comm] + have hall : ∀ v, φ v = 0 := fun v => hle (by rw [hspan]; trivial) + ext i k + have := congrFun (hall (Pi.single i 1)) k + simp only [φ, LinearMap.sub_apply, Matrix.vecMulLinear_apply, LinearMap.id_apply, + Pi.sub_apply, single_vecMul] at this + simp only [Matrix.one_apply] + simp only [Pi.zero_apply, Pi.single_apply] at this + have h3 := sub_eq_zero.1 this + rw [h3]; simp [eq_comm] + +end Rigid + +section Iff +variable {K Reg : Type*} [Field K] [Fintype Reg] [DecidableEq Reg] (h1 h2 : Reg) +local notation "σ" => Equiv.swap h1 h2 + +/-- (1), tail swap: undone iff both helpers end in V (under rigidity of the {0}-prefix). -/ +theorem tail_iff (V G0 : Reg → Prop) (hne : h1 ≠ h2) (F : Matrix Reg Reg K) + (hF1 : F h1 = Pi.single h1 1) (hF2 : F h2 = Pi.single h2 1) + (hrig : ∀ M : Matrix Reg Reg K, Blk G0 M → + (∀ x, x ≠ h1 → x ≠ h2 → ¬ V x → (F * M) x = F x) → M = 1) : + Undo V G0 F (rowSw σ F) ↔ V h1 ∧ V h2 := + ⟨tail_only_if h1 h2 V G0 hne F hF1 hF2 hrig, fun ⟨a, b⟩ => tail_if h1 h2 V G0 F a b⟩ + +/-- (1), head swap: undone iff both helpers are born in {0} (when some non-V row separates h1, h2). -/ +theorem head_iff (V G0 : Reg → Prop) (hne : h1 ≠ h2) (F : Matrix Reg Reg K) + (hw : ∃ x, ¬ V x ∧ F x h1 ≠ F x h2) : + Undo V G0 F (colSw σ F) ↔ G0 h1 ∧ G0 h2 := + ⟨head_only_if h1 h2 V G0 hne F hw, fun ⟨a, b⟩ => head_if h1 h2 V G0 F a b⟩ + +/-- Tail swap, spanning form of the rigidity hypothesis. -/ +theorem tail_iff_span (V G0 : Reg → Prop) (hne : h1 ≠ h2) (F : Matrix Reg Reg K) + (hF1 : F h1 = Pi.single h1 1) (hF2 : F h2 = Pi.single h2 1) + (hspan : Submodule.span K ((fun x => F x) '' {x | x ≠ h1 ∧ x ≠ h2 ∧ ¬ V x} ∪ + Set.range (fun k : {k // ¬ G0 k} => (Pi.single k.1 (1 : K) : Reg → K))) = ⊤) : + Undo V G0 F (rowSw σ F) ↔ V h1 ∧ V h2 := + tail_iff h1 h2 V G0 hne F hF1 hF2 fun M hM hfix => + rigid_of_span G0 _ F hspan M hM fun x hx => hfix x hx.1 hx.2.1 hx.2.2 + +lemma colSw_one (V : Reg → Prop) : colSw σ (1 : Matrix Reg Reg K) = rowSw σ 1 := by + ext i k + have : (σ i = k) ↔ (i = σ k) := + ⟨fun h => by rw [← h, swap_inv], fun h => by rw [h, swap_inv]⟩ + simp [colSw, rowSw, Matrix.one_apply, this] + +end Iff + +/-! ### Part C: ladder cost -/ +section Ladder +open JunkLB2 RelaySandwich + +/-- A helper's trajectory: birth dim `b`, end dim `e`, stay gaps before (`pre`) and after (`suf`) the +shared chart. -/ +structure Traj where + b : ℝ + e : ℝ + pre : List ℝ + suf : List ℝ + +/-- Per-helper ladder cost: span term minus the sum over stays (RelaySandwich.stopCost's accounting). -/ +noncomputable def Traj.cost (f : ℝ → ℝ) (t : Traj) : ℝ := + f (t.e - t.b) - ((t.pre ++ t.suf).map f).sum + +/-- Both helpers sit at the shared chart (dim `s`) and their gaps add up. -/ +def Traj.Wf (s : ℝ) (t : Traj) : Prop := t.b + t.pre.sum = s ∧ s + t.suf.sum = t.e + +/-- The swap (tail or head: same pair of trajectories, only the names differ). -/ +def Traj.swap (t1 t2 : Traj) : Traj × Traj := + (⟨t1.b, t2.e, t1.pre, t2.suf⟩, ⟨t2.b, t1.e, t2.pre, t1.suf⟩) + +theorem swap_wf (s : ℝ) (t1 t2 : Traj) (a : t1.Wf s) (b : t2.Wf s) : + (Traj.swap t1 t2).1.Wf s ∧ (Traj.swap t1 t2).2.Wf s := + ⟨⟨a.1, b.2⟩, ⟨b.1, a.2⟩⟩ + +/-- The multiset of stays is unchanged. -/ +theorem stays_multiset (t1 t2 : Traj) : + ((↑((Traj.swap t1 t2).1.pre ++ (Traj.swap t1 t2).1.suf ++ + ((Traj.swap t1 t2).2.pre ++ (Traj.swap t1 t2).2.suf)) : Multiset ℝ)) = + ↑(t1.pre ++ t1.suf ++ (t2.pre ++ t2.suf)) := by + simp only [Traj.swap, ← Multiset.coe_add] + abel + +theorem cost_stopCost (f : ℝ → ℝ) (e : ℝ) (k : ℕ) : + Traj.cost f ⟨0, e, List.replicate (k + 1) (e / (k + 1)), []⟩ = stopCost f e k := by + simp [Traj.cost, stopCost, List.map_replicate] + +/-- (2): the ladder change is exactly the rectangle difference of the span terms. -/ +theorem delta_eq (f : ℝ → ℝ) (t1 t2 : Traj) : + (Traj.swap t1 t2).1.cost f + (Traj.swap t1 t2).2.cost f - (t1.cost f + t2.cost f) = + (f (t2.e - t1.b) + f (t1.e - t2.b)) - (f (t1.e - t1.b) + f (t2.e - t2.b)) := by + simp only [Traj.cost, Traj.swap, List.map_append, List.sum_append] + ring + +/-- Both helpers end in V (same dim): ladder change 0. -/ +theorem delta_zero_end (f : ℝ → ℝ) (t1 t2 : Traj) (h : t1.e = t2.e) : + (Traj.swap t1 t2).1.cost f + (Traj.swap t1 t2).2.cost f - (t1.cost f + t2.cost f) = 0 := by + rw [delta_eq, h]; ring + +/-- Both helpers born in {0} (same dim 0): ladder change 0. -/ +theorem delta_zero_birth (f : ℝ → ℝ) (t1 t2 : Traj) (h : t1.b = t2.b) : + (Traj.swap t1 t2).1.cost f + (Traj.swap t1 t2).2.cost f - (t1.cost f + t2.cost f) = 0 := by + rw [delta_eq, h]; ring + +end Ladder + +/-! ### Part D: the law and the converse witness -/ +section Law +open JunkLB2 + +variable {K Reg : Type*} [Field K] [Fintype Reg] [DecidableEq Reg] (h1 h2 : Reg) +local notation "σ" => Equiv.swap h1 h2 + +/-- SWAP-NULL: a legal (hub-undoable) swap has ladder change 0 (ends of V-enders share the dim of V, +{0}-born helpers share dim 0). -/ +theorem swap_null (f : ℝ → ℝ) (V G0 : Reg → Prop) (dV : ℝ) (t1 t2 : Traj) (hne : h1 ≠ h2) + (hV1 : V h1 → t1.e = dV) (hV2 : V h2 → t2.e = dV) + (hG1 : G0 h1 → t1.b = 0) (hG2 : G0 h2 → t2.b = 0) + (hu : Undo V G0 (1 : Matrix Reg Reg K) (rowSw σ 1)) : + (Traj.swap t1 t2).1.cost f + (Traj.swap t1 t2).2.cost f - (t1.cost f + t2.cost f) = 0 := by + rcases (undo_one_iff h1 h2 V G0 hne).1 hu with ⟨a, b⟩ | ⟨a, b⟩ + · exact delta_zero_end f t1 t2 ((hV1 a).trans (hV2 b).symm) + · exact delta_zero_birth f t1 t2 ((hG1 a).trans (hG2 b).symm) + +/-- (3), contrapositive: a nonzero ladder change cannot be hub-undone. -/ +theorem nonzero_not_undoable (f : ℝ → ℝ) (V G0 : Reg → Prop) (dV : ℝ) (t1 t2 : Traj) + (hne : h1 ≠ h2) + (hV1 : V h1 → t1.e = dV) (hV2 : V h2 → t2.e = dV) + (hG1 : G0 h1 → t1.b = 0) (hG2 : G0 h2 → t2.b = 0) + (hd : (Traj.swap t1 t2).1.cost f + (Traj.swap t1 t2).2.cost f - (t1.cost f + t2.cost f) ≠ 0) : + ¬ Undo V G0 (1 : Matrix Reg Reg K) (rowSw σ 1) := + fun hu => hd (swap_null (K := K) h1 h2 f V G0 dV t1 t2 hne hV1 hV2 hG1 hG2 hu) + +/-- The numerical core: 7 ln 7 + 4 ln 4 < 2 ln 2 + 9 ln 9. -/ +theorem witness_num : fL (9 - 5) + fL (7 - 0) - (fL (7 - 5) + fL (9 - 0)) < 0 := by + have h : (7 : ℝ) * Real.log 7 + 6 * Real.log 2 < 18 * Real.log 3 := by + have := Real.log_lt_log (by positivity : (0 : ℝ) < 7 ^ 7 * 2 ^ 6) (by norm_num : (7 : ℝ) ^ 7 * 2 ^ 6 < 3 ^ 18) + rw [Real.log_mul (by positivity) (by positivity), Real.log_pow, Real.log_pow, Real.log_pow] at this + push_cast at this + exact this + have h4 : Real.log 4 = 2 * Real.log 2 := by + rw [show (4 : ℝ) = 2 ^ 2 by norm_num, Real.log_pow]; norm_num + have h9 : Real.log 9 = 2 * Real.log 3 := by + rw [show (9 : ℝ) = 3 ^ 2 by norm_num, Real.log_pow]; norm_num + unfold fL + norm_num + rw [h4, h9] + linarith + +end Law + +/-- Concrete witness (Reg = Fin 2; helper 0 born dim 5, ends dim 7, in neither hub; helper 1 born {0}, +ends in V of dim 9; shared chart dim 6). Its ladder change is strictly negative (f = r ln r, about +-1.995), and the swap, tail or head, cannot be undone by any V mix and {0}-prefix. -/ +theorem converse_witness : + let t1 : Traj := ⟨5, 7, [1], [1]⟩ + let t2 : Traj := ⟨0, 9, [6], [3]⟩ + t1.Wf 6 ∧ t2.Wf 6 ∧ + ((Traj.swap t1 t2).1.cost JunkLB2.fL + (Traj.swap t1 t2).2.cost JunkLB2.fL + - (t1.cost JunkLB2.fL + t2.cost JunkLB2.fL) < 0) ∧ + ¬ Undo (fun r : Fin 2 => r = 1) (fun r : Fin 2 => r = 1) (1 : Matrix (Fin 2) (Fin 2) ℚ) + (rowSw (Equiv.swap 0 1) 1) ∧ + ¬ Undo (fun r : Fin 2 => r = 1) (fun r : Fin 2 => r = 1) (1 : Matrix (Fin 2) (Fin 2) ℚ) + (colSw (Equiv.swap 0 1) 1) := by + intro t1 t2 + have hne : (0 : Fin 2) ≠ 1 := by decide + have hn : ¬ Undo (fun r : Fin 2 => r = 1) (fun r : Fin 2 => r = 1) (1 : Matrix (Fin 2) (Fin 2) ℚ) + (rowSw (Equiv.swap 0 1) 1) := by + rw [undo_one_iff 0 1 _ _ hne]; decide + refine ⟨by norm_num [Traj.Wf, t1], by norm_num [Traj.Wf, t2], ?_, hn, ?_⟩ + · rw [delta_eq] + simpa [t1, t2] using witness_num + · rw [colSw_one 0 1 (fun r : Fin 2 => r = 1)]; exact hn + +/-- Scope of the per-kind iff: with identity finals and both helpers in G0 but not in V, the TAIL +swap IS undone (by the prefix), so "tail swap legal iff both end in V" needs the rigidity hypothesis. -/ +theorem tail_prefix_counterexample : + Undo (fun _ : Fin 2 => False) (fun _ : Fin 2 => True) (1 : Matrix (Fin 2) (Fin 2) ℚ) + (rowSw (Equiv.swap 0 1) 1) ∧ ¬ (False ∧ False) := by + refine ⟨?_, by simp⟩ + rw [undo_one_iff 0 1 _ _ (by decide)]; simp + +#print axioms tail_run +#print axioms head_run +#print axioms gadget_legal +#print axioms tail_iff +#print axioms tail_iff_span +#print axioms head_iff +#print axioms undo_one_iff +#print axioms delta_eq +#print axioms swap_null +#print axioms converse_witness +#print axioms tail_prefix_counterexample +#print axioms stays_multiset +#print axioms cost_stopCost + +end SwapNull diff --git a/research/p104-tiered-ceiling/lean/Nov15/SwapNull.md b/research/p104-tiered-ceiling/lean/Nov15/SwapNull.md new file mode 100644 index 0000000000..c8950480ee --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/SwapNull.md @@ -0,0 +1,24 @@ +# SwapNull.lean: LAWBUILD M3 law SWAP-NULL. No sorry, 8 s, 2.45 GB RSS +Nov 17. Imports TokenCancel (op model), SwapWord (`run_append`), RelaySandwich (`stopCost`, `fL` via JunkLB2). Axioms: [propext, Classical.choice, Quot.sound]. +Source: (internal notes) HubSettle's V mix and {0}-prefix are modelled as `Blk V` / `Blk G0` matrices (left / right multiplication). + +**Gadget (4 ops, at the shared chart c):** `add h1 h2 (+1); add h2 h1 (-1); add h1 h2 (+1); scale h2 (-1)`. `gadget_run`: rows of h1,h2 exchanged, nothing else changes; `gadget_legal`. +- `tail_run`: gadget, then every later event renamed h1<->h2 => final state = unswapped final with rows h1,h2 exchanged (F' = P F). +- `head_run`: earlier events renamed, gadget, original later events (sigma-symmetric start) => every final row has its h1/h2 coordinates exchanged (F' = F P). + +**(1) legality.** `Undo V G0 F F'` := exists V mix L (identity off V x V) and prefix M (identity off G0 x G0) with L F' M = F. +- `tail_if`/`head_if`: both in V (tail) / both in G0 (head) => undone (L = P, resp. M = P). +- `undo_one_iff` (identity finals, no other hypothesis): undone iff (both V) or (both G0). +- `tail_iff`, `tail_iff_span`: tail swap undone iff both V, GIVEN rigidity of the prefix (the unchanged non-V rows pin M = 1; `rigid_of_span` derives it from a spanning condition). +- `head_iff`: head swap undone iff both G0, GIVEN a non-V row with F x h1 != F x h2. + +**(2) ladder.** `Traj.cost f t = f(e-b) - sum f(gaps)` (`cost_stopCost`: equals RelaySandwich.stopCost on the equal-move ladder). `Traj.swap`: (b1,e2,pre1++suf2), (b2,e1,pre2++suf1). +- `stays_multiset`: the multiset of stays is unchanged; `swap_wf`: swapped trajectories are again consistent. +- `delta_eq`: change = f(e2-b1)+f(e1-b2)-f(e1-b1)-f(e2-b2). +- `delta_zero_end` (e1 = e2, both end in V), `delta_zero_birth` (b1 = b2 = 0), `swap_null`: hub-undoable => ladder change 0. + +**(3) converse.** `nonzero_not_undoable`: nonzero change => not undoable. `converse_witness` (concrete): helper 0 born dim 5 ends 7 (no hub), helper 1 born {0} ends V (dim 9): f = r ln r change = 7 ln 7 + 4 ln 4 - 2 ln 2 - 9 ln 9 ~ -1.995 < 0 (`witness_num`, 7^7 2^6 < 3^18), and neither the tail nor the head swap is undone by any L, M. + +**Finding (M3 wording needs scope).** "tswap legal iff both end in V; hswap iff both born in {0}" is true only with a hypothesis: `tail_prefix_counterexample` (identity finals, both helpers in G0, none in V) is a tail swap undone by the prefix alone. Corrected statement: for identity-final helpers the swap is undone iff (both V) or (both G0) (`undo_one_iff`); the per-kind iff needs prefix rigidity (tail) / a separating non-V row (head). In the real word the non-V rows do pin the prefix (M3's controls XT/XH fail at settle3), but that is an input [C], not a consequence. + +**Scope.** Matrix-level model: L, M are not required invertible (strengthens only-if). The M3 census numbers (8,282 pairs, 7,390 absorbable) are data, not re-proved. Mixed gadget placement (swap back later) is not modelled. diff --git a/research/p104-tiered-ceiling/lean/Nov15/SwapWord.lean b/research/p104-tiered-ceiling/lean/Nov15/SwapWord.lean new file mode 100644 index 0000000000..49dfdcbae8 --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/SwapWord.lean @@ -0,0 +1,181 @@ +/- +SwapWord, See SwapWord.md. + +The SWAPBUILD edit (internal notes, from BIG/TOKENRANK TR2): at a moment when helper h's row +is exactly e_h, inject `j += c·h` (data: c = −1, just before the native's own `h += j`, so the pair is +the swap `j -= h; h += j`). General facts in TokenCancel's op model: +* `run_diff`: the run is affine in the rows; the difference of two runs with equal locations is the + run of the difference with births read as INITs. +* `inject`: the injection changes the final rows ONLY in column h: final' r = final r + δ r • e_h. +* `inject_two`: two injections (457 → 242, 461 → X10) change the final rows only in columns h1, h2. +* `inject_col`: every final row is unchanged on every column k ≠ h, for every register (non-V-enders included). +* `absorb`: the debt is absorbed by the V mix: if e_h lies in the span of the V targets (h ends at V + with target e_h), the non-V-enders end on target, the original V-ender rows lie in that span and + targets are independent, then the edited run has a V mix iff it is loss-free. + +Build (imports the RankLawC olean; see RankLawC.lean for the chain): + lake env lean -o .lake/build/lib/lean/Nov15/RankLawC.olean Nov15/RankLawC.lean + lake env lean Nov15/SwapWord.lean +-/ +import Nov15.RankLawC + +set_option linter.unusedSectionVars false + +namespace SwapWord +open Submodule Module TokenCancel RankLaw + +variable {K Reg C : Type*} [Field K] [DecidableEq Reg] [DecidableEq C] + +/-- Births read as INITs (a birth writes the same e_i in both runs, so the difference row is 0). -/ +def unborn : Ev K Reg C → Ev K Reg C + | .born i c => .init i c + | e => e + +theorem run_append (s : St K Reg C) (p q : List (Ev K Reg C)) : + run s (p ++ q) = run (run s p) q := by + induction p generalizing s with + | nil => rfl + | cons e p ih => exact ih (step s e) + +lemma upd_sub (f g : Reg → Reg → K) (i : Reg) (a b : Reg → K) : + Function.update f i a - Function.update g i b = Function.update (f - g) i (a - b) := by + funext k; by_cases hk : k = i + · subst hk; simp + · simp [Function.update_of_ne hk] + +/-- One step of the difference. -/ +theorem step_diff (s t : St K Reg C) (hl : s.loc = t.loc) (e : Ev K Reg C) : + (step t e).loc = (step s e).loc ∧ + (step t e).row - (step s e).row = (step ⟨t.row - s.row, s.loc⟩ (unborn e)).row := by + cases e with + | born i c => exact ⟨by simp [step, hl], by simp [step, unborn, upd_sub]⟩ + | init i c => exact ⟨by simp [step, hl], by simp [step, unborn, upd_sub]⟩ + | move i c => exact ⟨by simp [step, hl], by simp [step, unborn]⟩ + | add i j a c => + refine ⟨by simp [step, hl], ?_⟩ + simp only [step, unborn, upd_sub, Pi.sub_apply] + congr 1; rw [smul_sub]; abel + | scale i u c => exact ⟨by simp [step, hl], by simp [step, unborn, upd_sub, smul_sub]⟩ + | clear i c => exact ⟨by simp [step, hl], by simp [step, unborn, upd_sub]⟩ + | copy i j c => exact ⟨by simp [step, hl], by simp [step, unborn, upd_sub]⟩ + +/-- **Difference law.** Two runs of the same events from states with equal locations differ by the +run of the difference state (births read as INITs). -/ +theorem run_diff : ∀ (evs : List (Ev K Reg C)) (s t : St K Reg C), s.loc = t.loc → + (run t evs).loc = (run s evs).loc ∧ + (run t evs).row - (run s evs).row = (run ⟨t.row - s.row, s.loc⟩ (evs.map unborn)).row + | [], s, t, hl => ⟨hl.symm, rfl⟩ + | e :: es, s, t, hl => by + obtain ⟨h1, h2⟩ := step_diff s t hl e + have ih := run_diff es (step s e) (step t e) h1.symm + refine ⟨ih.1, ?_⟩ + simp only [run, List.map_cons] + rw [ih.2] + have hst : (⟨(step t e).row - (step s e).row, (step s e).loc⟩ : St K Reg C) = + step ⟨t.row - s.row, s.loc⟩ (unborn e) := by + cases e <;> simp only [step, unborn] at h2 ⊢ <;> rw [h2] + rw [hst] + +/-- With no births, every op keeps all rows inside a fixed subspace P. -/ +theorem rows_in_run (P : Submodule K (Reg → K)) : + ∀ (evs : List (Ev K Reg C)) (d : St K Reg C), (∀ r, d.row r ∈ P) → + ∀ r, (run d (evs.map unborn)).row r ∈ P + | [], d, hd => hd + | e :: es, d, hd => by + simp only [List.map_cons, run] + refine rows_in_run P es _ (fun r => ?_) + by_cases hr : r = (match e with + | .born i _ | .init i _ | .move i _ | .add i _ _ _ | .scale i _ _ | .clear i _ | .copy i _ _ => i) + · cases e <;> simp only [step, unborn] at hr ⊢ <;> subst hr <;> + simp [P.zero_mem, P.add_mem, P.smul_mem, hd] + · cases e <;> simp only [step, unborn] at hr ⊢ <;> simp [Function.update_of_ne hr, hd] + +/-- **Injection law.** If h's row is exactly e_h after the prefix p, injecting `j += c·h` there +changes the final rows only by multiples of e_h. -/ +theorem inject (s : St K Reg C) (p q : List (Ev K Reg C)) (h j : Reg) (c : K) (ch : C) + (hrow : (run s p).row h = Pi.single h 1) : + ∃ δ : Reg → K, ∀ r, (run s (p ++ .add j h c ch :: q)).row r = + (run s (p ++ q)).row r + δ r • (Pi.single h 1 : Reg → K) := by + set s0 := run s p + set t := step s0 (.add j h c ch) + have hl : s0.loc = t.loc := rfl + obtain ⟨-, hd⟩ := run_diff q s0 t hl + have hin : ∀ r, (t.row - s0.row) r ∈ K ∙ (Pi.single h 1 : Reg → K) := by + intro r + by_cases hr : r = j + · subst hr; simp [t, step, hrow, mem_span_singleton] + · simp [t, step, Function.update_of_ne hr] + have hall := rows_in_run (K ∙ (Pi.single h 1 : Reg → K)) q ⟨t.row - s0.row, s0.loc⟩ hin + have : ∀ r, ∃ a : K, a • (Pi.single h 1 : Reg → K) = + (run t q).row r - (run s0 q).row r := by + intro r + have e := congrFun hd r + rw [Pi.sub_apply] at e + rw [e]; exact mem_span_singleton.1 (hall r) + choose δ hδ using this + refine ⟨δ, fun r => ?_⟩ + rw [run_append, run_append] + change (run t q).row r = _ + rw [← sub_add_cancel ((run t q).row r) ((run s0 q).row r), ← hδ r, add_comm] + +/-- Column form: every final row (non-V-enders included) is unchanged on every column k ≠ h. -/ +theorem inject_col (s : St K Reg C) (p q : List (Ev K Reg C)) (h j : Reg) (c : K) (ch : C) + (hrow : (run s p).row h = Pi.single h 1) (r k : Reg) (hk : k ≠ h) : + (run s (p ++ .add j h c ch :: q)).row r k = (run s (p ++ q)).row r k := by + obtain ⟨δ, hδ⟩ := inject s p q h j c ch hrow + rw [hδ r]; simp [hk] + +/-- **Two injections** (the SWAPBUILD "both" word: 457 → 242, then 461 → X10). Hypotheses: h1 = e_h1 +at the first point of the unedited prefix, and h2 = e_h2 at the second point of the once-edited word. -/ +theorem inject_two (s : St K Reg C) (p1 q1 q2 : List (Ev K Reg C)) (h1 j1 h2 j2 : Reg) (c1 c2 : K) + (ch1 ch2 : C) + (hrow1 : (run s p1).row h1 = Pi.single h1 1) + (hrow2 : (run s (p1 ++ .add j1 h1 c1 ch1 :: q1)).row h2 = Pi.single h2 1) : + ∃ δ1 δ2 : Reg → K, ∀ r, + (run s (p1 ++ .add j1 h1 c1 ch1 :: q1 ++ .add j2 h2 c2 ch2 :: q2)).row r = + (run s (p1 ++ q1 ++ q2)).row r + δ1 r • (Pi.single h1 1 : Reg → K) + + δ2 r • (Pi.single h2 1 : Reg → K) := by + obtain ⟨δ2, hδ2⟩ := inject s (p1 ++ .add j1 h1 c1 ch1 :: q1) q2 h2 j2 c2 ch2 hrow2 + obtain ⟨δ1, hδ1⟩ := inject s p1 (q1 ++ q2) h1 j1 c1 ch1 hrow1 + refine ⟨δ1, δ2, fun r => ?_⟩ + rw [hδ2 r] + have e1 : p1 ++ Ev.add j1 h1 c1 ch1 :: q1 ++ q2 = p1 ++ Ev.add j1 h1 c1 ch1 :: (q1 ++ q2) := by simp + rw [e1, hδ1 r, List.append_assoc] + +/-- Two-column form: every final row is unchanged on every column outside {h1, h2}. -/ +theorem inject_two_col (s : St K Reg C) (p1 q1 q2 : List (Ev K Reg C)) (h1 j1 h2 j2 : Reg) + (c1 c2 : K) (ch1 ch2 : C) + (hrow1 : (run s p1).row h1 = Pi.single h1 1) + (hrow2 : (run s (p1 ++ .add j1 h1 c1 ch1 :: q1)).row h2 = Pi.single h2 1) + (r k : Reg) (hk1 : k ≠ h1) (hk2 : k ≠ h2) : + (run s (p1 ++ .add j1 h1 c1 ch1 :: q1 ++ .add j2 h2 c2 ch2 :: q2)).row r k = + (run s (p1 ++ q1 ++ q2)).row r k := by + obtain ⟨δ1, δ2, hδ⟩ := inject_two s p1 q1 q2 h1 j1 h2 j2 c1 c2 ch1 ch2 hrow1 hrow2 + rw [hδ r]; simp [hk1, hk2] + +/-- **The debt is absorbed by the V mix.** Let `evs` be the edited (hub-deleted) word and `X0` the +unedited end rows. Suppose the edited end rows differ from X0 only along e_h (`inject`), the +non-V-enders end on target (the TR2 column condition, data), the unedited V-ender rows lie in +B = span V targets, e_h ∈ B (h ends at V with target e_h) and B ⊓ N = ⊥. Then the edited run has a +V mix iff it is loss-free. -/ +theorem absorb [Fintype Reg] (z V : C) (s : St K Reg C) (T : Finset Reg) (evs : List (Ev K Reg C)) + (hL : Legal z V s evs) (hN : ∀ e ∈ evs, NZ e) (hG : Good s T) (hS : Sp s = TS T) + (Rf : Reg → Reg → K) (G1 : Finset Reg) (h : Reg) (X0 : Reg → Reg → K) (δ : Reg → K) + (hX : ∀ r, (run s evs).row r = X0 r + δ r • (Pi.single h 1 : Reg → K)) + (hNon : ∀ r ∉ G1, (run s evs).row r = Rf r) + (hTgt : span K (Set.range Rf) = TS (tokRun T evs)) + (hX0 : ∀ g ∈ G1, X0 g ∈ span K (Rf '' (G1 : Set Reg))) + (he : (Pi.single h 1 : Reg → K) ∈ span K (Rf '' (G1 : Set Reg))) + (hBN : span K (Rf '' (G1 : Set Reg)) ⊓ span K (Rf '' (G1 : Set Reg)ᶜ) = ⊥) : + VMix (run s evs).row Rf G1 ↔ ¬ Loss s evs := by + rw [RankLawC.rank_law_indep z V s T evs hL hN hG hS Rf G1 hNon hTgt hBN] + refine ⟨And.left, fun hl => ⟨hl, fun g hg => ?_⟩⟩ + rw [hX g]; exact add_mem (hX0 g hg) (smul_mem _ _ he) + +end SwapWord + +#print axioms SwapWord.absorb +#print axioms SwapWord.inject_two_col +#print axioms SwapWord.inject_col +#print axioms RankLawC.rank_law_proj +#print axioms RankLawC.rank_law_of_gen diff --git a/research/p104-tiered-ceiling/lean/Nov15/SwapWord.md b/research/p104-tiered-ceiling/lean/Nov15/SwapWord.md new file mode 100644 index 0000000000..e4c791cf91 --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/SwapWord.md @@ -0,0 +1,37 @@ +# SwapWord.lean: the SWAPBUILD two-swap edit (h457 → 242, h461 → X10). No sorry, ~5 s, 2.1 GB RSS +Imports the RankLawC olean. Axioms: [propext, Classical.choice, Quot.sound]. +Source: internal notes (not included). + +**The edit (data).** After rebirth (h = e_h at its first chart), the edit injects `j += −1·h` just before the native's own `h += j`. Together they are the swap. +- 457 → 242 at index 11392 of the hub-deleted mid program; 461 → X10 at index 11498. +- h = e_h holds at both points; the second is checked in the once-edited word (Nov15/swapword_data.py). + +**General lemmas** (TokenCancel's op model, any field): +- `run_diff`: two runs of the same events from states with equal locations differ by the run of the difference state, with births read as INITs. +- `rows_in_run`: with no births, all rows stay in any subspace P that contains them initially. +- **`inject`**: if h's row is e_h after prefix p, injecting `add j h c` changes every final row by δ r • e_h only. + - `inject_col`: every row, non-V-enders included, is unchanged on every column k ≠ h. +- `inject_two`, `inject_two_col`: the same for two injections (h1 = e_h1 in the unedited prefix, h2 = e_h2 in the once-edited one). The change is δ1 e_h1 + δ2 e_h2. +- **`absorb`** (the debt is absorbed by the V mix). Hypotheses: + - the edited rows = X0 + δ e_h; + - non-V-enders on target (TR2); + - X0[G1] ⊆ B; + - e_h ∈ B; + - B ⊓ N = ⊥. + + Then: V mix for the edited run ⟺ edited run is loss-free (via RankLawC.rank_law_indep). + +**Data (exact, swapword_data.py).** +- Debt support is exactly column {h}. +- Non-V-enders changed: 157/160/210/219 for 457 (column 457: −1/2 → 0) and 120/179/192/207 for 461 (column 461: +1 → 0). +- Every non-G0 mismatch vs native Rf on non-V-enders: 4 → 0. +- V-enders absorb the debt; 457 and 461 are themselves V-enders with Rf h = e_h, so e_h ∈ B. +- Loss-freeness/joint feasibility is the JointG + exact replay data (SWAPBUILD: final rows == native rows). + +**Scope.** +- `absorb` is stated for rows after the z-prefix. HubSettle's [X_n | X_0·M] acts only on G0 columns, and after rebirth h ∉ G0, so the e_h debt commutes with it. + +**Finding (prose false as written).** "The swap preserves every non-V-ender row exactly" is false against the unswapped (rebirth-only) word: it changes 4 non-V-ender rows per swap. +- True form: the swap changes final rows only in column e_h (`inject_col`). On non-V-enders the change is exactly the TR2 canceller, which zeroes their column h (now non-G0 after rebirth, so the z-hub can no longer clean it). +- Minimal fix: "preserves every row off column h; on non-V-enders it cancels column h (TR2), and the remaining e_h debt sits on V-enders, absorbed by the V mix because e_h ∈ span V targets (h is a V-ender)". +- Without e_h ∈ B and with B ⊓ N = ⊥, a nonzero V-ender debt can never be absorbed. diff --git a/research/p104-tiered-ceiling/lean/Nov15/TokenCancel.lean b/research/p104-tiered-ceiling/lean/Nov15/TokenCancel.lean new file mode 100644 index 0000000000..5686668ec3 --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/TokenCancel.lean @@ -0,0 +1,452 @@ +/- +BIG-TOKENCANCEL T1 (hub blindness) and T2 (difference lemma), Source: internal notes See TokenCancel.md. + +Op model: registers `Reg`, charts `C` with two hubs `z` (= {0}) and `V`; rows in initial-row +coordinates `Reg → K`. Events carry their chart. Legal = co-presence plus the two [C] facts of +T1(a)/(b): no MOVE enters z and no MOVE leaves V. +-/ +import Mathlib.LinearAlgebra.Span.Basic +import Mathlib.LinearAlgebra.Pi +import Mathlib.Tactic.Abel +import Mathlib.Algebra.BigOperators.Fin + +set_option linter.unusedSectionVars false + +namespace TokenCancel + +inductive Ev (K Reg C : Type*) + | born (i : Reg) (c : C) + | init (i : Reg) (c : C) + | move (i : Reg) (c : C) + | add (i j : Reg) (a : K) (c : C) + | scale (i : Reg) (u : K) (c : C) + | clear (i : Reg) (c : C) + | copy (i j : Reg) (c : C) + +structure St (K Reg C : Type*) where + row : Reg → Reg → K + loc : Reg → Option C + +variable {K Reg C : Type*} [Field K] [DecidableEq Reg] [DecidableEq C] + +def step (s : St K Reg C) : Ev K Reg C → St K Reg C + | .born i c => ⟨Function.update s.row i (Pi.single i 1), Function.update s.loc i (some c)⟩ + | .init i c => ⟨Function.update s.row i 0, Function.update s.loc i (some c)⟩ + | .move i c => ⟨s.row, Function.update s.loc i (some c)⟩ + | .add i j a _ => ⟨Function.update s.row i (s.row i + a • s.row j), s.loc⟩ + | .scale i u _ => ⟨Function.update s.row i (u • s.row i), s.loc⟩ + | .clear i _ => ⟨Function.update s.row i 0, s.loc⟩ + | .copy i j _ => ⟨Function.update s.row i (s.row j), s.loc⟩ + +def run (s : St K Reg C) : List (Ev K Reg C) → St K Reg C + | [] => s + | e :: es => run (step s e) es + +variable (z V : C) + +/-- Legality: co-presence at the event's chart; births/INITs of absent registers; +MOVEs never enter `z` and never leave `V` (T1(a), T1(b), checked [C] on #7623). -/ +def LegalEv (s : St K Reg C) : Ev K Reg C → Prop + | .born i _ => s.loc i = none + | .init i _ => s.loc i = none + | .move i c => ∃ c0, s.loc i = some c0 ∧ c0 ≠ V ∧ c ≠ z + | .add i j _ c => i ≠ j ∧ s.loc i = some c ∧ s.loc j = some c + | .scale i _ c => s.loc i = some c + | .clear i c => s.loc i = some c + | .copy i j c => s.loc i = some c ∧ s.loc j = some c + +def Legal : St K Reg C → List (Ev K Reg C) → Prop + | _, [] => True + | s, e :: es => LegalEv z V s e ∧ Legal (step s e) es + +/-- An op (not a birth/INIT/MOVE) at a hub. -/ +def hubOp : Ev K Reg C → Prop + | .add _ _ _ c | .scale _ _ c | .clear _ c | .copy _ _ c => c = z ∨ c = V + | _ => False + +instance (e : Ev K Reg C) : Decidable (hubOp z V e) := by + cases e <;> simp only [hubOp] <;> infer_instance + +variable (h : Reg) + +/-- The interior coefficient program: tracks the e_h-coefficient, ignoring every hub op. -/ +def sig (σ : Reg → K) : Ev K Reg C → Reg → K + | .born i _ => Function.update σ i (if i = h then 1 else 0) + | .init i _ => Function.update σ i 0 + | .move _ _ => σ + | .add i j a c => if c = z ∨ c = V then σ else Function.update σ i (σ i + a * σ j) + | .scale i u c => if c = z ∨ c = V then σ else Function.update σ i (u * σ i) + | .clear i c => if c = z ∨ c = V then σ else Function.update σ i 0 + | .copy i j c => if c = z ∨ c = V then σ else Function.update σ i (σ j) + +def sigRun (σ : Reg → K) : List (Ev K Reg C) → Reg → K + | [] => σ + | e :: es => sigRun (sig z V h σ e) es + +/-- The program is blind to hub ops: it equals the program run on the interior subsequence. -/ +theorem sigRun_filter (σ : Reg → K) (evs : List (Ev K Reg C)) : + sigRun z V h σ evs = sigRun z V h σ (evs.filter fun e => ¬ hubOp z V e) := by + induction evs generalizing σ with + | nil => rfl + | cons e es ih => + by_cases he : hubOp z V e + · have : sig z V h σ e = σ := by + cases e <;> simp_all [hubOp, sig] + simp [sigRun, he, this, ih] + · simp [sigRun, he, ih] + +/-- Invariant: rows not at V carry the program's e_h-coefficient; rows at z carry 0. -/ +def Inv (s : St K Reg C) (σ : Reg → K) : Prop := + (∀ r, s.loc r ≠ some V → s.row r h = σ r) ∧ (∀ r, s.loc r = some z → s.row r h = 0) + +lemma inv_update (s : St K Reg C) (σ σ' : Reg → K) (i : Reg) (nr : Reg → K) + (hI : Inv z V h s σ) (hσ : ∀ r, r ≠ i → σ' r = σ r) + (hnew : s.loc i ≠ some V → nr h = σ' i) (hz : s.loc i = some z → nr h = 0) : + Inv z V h ⟨Function.update s.row i nr, s.loc⟩ σ' := by + refine ⟨fun r hr => ?_, fun r hr => ?_⟩ + · by_cases hri : r = i + · subst hri; simpa using hnew hr + · simp only [Function.update_of_ne hri]; rw [hσ r hri]; exact hI.1 r hr + · by_cases hri : r = i + · subst hri; simpa using hz hr + · simp only [Function.update_of_ne hri]; exact hI.2 r hr + +theorem inv_step (s : St K Reg C) (σ : Reg → K) (e : Ev K Reg C) + (hI : Inv z V h s σ) (hL : LegalEv z V s e) (hb : ∀ c, e = .born h c → c ≠ z) : + Inv z V h (step s e) (sig z V h σ e) := by + have hI1 := hI.1 + have hI2 := hI.2 + -- coefficient of a register present at chart c + have atz : ∀ i c, s.loc i = some c → c = z → s.row i h = 0 := fun i c hi hc => + hI2 i (hc ▸ hi) + have notV : ∀ i c, s.loc i = some c → c ≠ V → s.row i h = σ i := fun i c hi hc => + hI1 i (by rw [hi]; simpa using hc) + cases e with + | born i c => + refine ⟨fun r _ => ?_, fun r hr => ?_⟩ + · by_cases hri : r = i + · subst hri; simp [step, sig, Pi.single_apply, eq_comm] + · simp only [step, sig, Function.update_of_ne hri] at * + exact hI1 r (by simpa [step, Function.update_of_ne hri] using ‹_›) + · by_cases hri : r = i + · subst hri + simp only [step, Function.update_self, Option.some.injEq] at hr + have : r ≠ h := fun hrh => hb c (by rw [hrh]) hr + simp [step, this.symm] + · simp only [step, Function.update_of_ne hri] at hr ⊢; exact hI2 r hr + | init i c => + refine ⟨fun r hr => ?_, fun r hr => ?_⟩ + · by_cases hri : r = i + · subst hri; simp [step, sig] + · simp only [step, sig, Function.update_of_ne hri] at hr ⊢; exact hI1 r hr + · by_cases hri : r = i + · subst hri; simp [step] + · simp only [step, Function.update_of_ne hri] at hr ⊢; exact hI2 r hr + | move i c => + obtain ⟨c0, hc0, hc0V, hcz⟩ := hL + refine ⟨fun r hr => ?_, fun r hr => ?_⟩ + · by_cases hri : r = i + · subst hri; exact hI1 r (by rw [hc0]; simpa using hc0V) + · simp only [step, sig, Function.update_of_ne hri] at hr ⊢; exact hI1 r hr + · by_cases hri : r = i + · subst hri; simp [step] at hr; exact absurd hr hcz + · simp only [step, Function.update_of_ne hri] at hr ⊢; exact hI2 r hr + | add i j a c => + obtain ⟨hij, hi, hj⟩ := hL + by_cases hc : c = z ∨ c = V + · have hs : sig z V h σ (.add i j a c) = σ := by simp [sig, hc] + rw [hs] + apply inv_update z V h s σ σ i _ hI (fun _ _ => rfl) + · intro hiV + have hcV : c ≠ V := fun h' => hiV (h' ▸ hi) + have hcz : c = z := hc.resolve_right hcV + simp [atz i c hi hcz, atz j c hj hcz, ← notV i c hi hcV] + · intro hiz + have hcz : c = z := by rw [hi] at hiz; exact Option.some.inj hiz + simp [atz i c hi hcz, atz j c hj hcz] + · push Not at hc + have hs : sig z V h σ (.add i j a c) = Function.update σ i (σ i + a * σ j) := by + simp [sig, hc] + rw [hs] + apply inv_update z V h s σ _ i _ hI (fun r hr => Function.update_of_ne hr _ _) + · intro _; simp [notV i c hi hc.2, notV j c hj hc.2] + · intro hiz; rw [hi] at hiz; exact absurd (Option.some.inj hiz) hc.1 + | scale i u c => + have hi : s.loc i = some c := hL + by_cases hc : c = z ∨ c = V + · have hs : sig z V h σ (.scale i u c) = σ := by simp [sig, hc] + rw [hs] + apply inv_update z V h s σ σ i _ hI (fun _ _ => rfl) + · intro hiV + have hcV : c ≠ V := fun h' => hiV (h' ▸ hi) + have hcz : c = z := hc.resolve_right hcV + simp [atz i c hi hcz, ← notV i c hi hcV] + · intro hiz + have hcz : c = z := by rw [hi] at hiz; exact Option.some.inj hiz + simp [atz i c hi hcz] + · push Not at hc + have hs : sig z V h σ (.scale i u c) = Function.update σ i (u * σ i) := by + simp [sig, hc] + rw [hs] + apply inv_update z V h s σ _ i _ hI (fun r hr => Function.update_of_ne hr _ _) + · intro _; simp [notV i c hi hc.2] + · intro hiz; rw [hi] at hiz; exact absurd (Option.some.inj hiz) hc.1 + | clear i c => + have hi : s.loc i = some c := hL + by_cases hc : c = z ∨ c = V + · have hs : sig z V h σ (.clear i c) = σ := by simp [sig, hc] + rw [hs] + apply inv_update z V h s σ σ i _ hI (fun _ _ => rfl) + · intro hiV + have hcV : c ≠ V := fun h' => hiV (h' ▸ hi) + have hcz : c = z := hc.resolve_right hcV + simp [← notV i c hi hcV, atz i c hi hcz] + · intro _; simp + · push Not at hc + have hs : sig z V h σ (.clear i c) = Function.update σ i 0 := by simp [sig, hc] + rw [hs] + apply inv_update z V h s σ _ i _ hI (fun r hr => Function.update_of_ne hr _ _) + · intro _; simp + · intro _; simp + | copy i j c => + obtain ⟨hi, hj⟩ := hL + by_cases hc : c = z ∨ c = V + · have hs : sig z V h σ (.copy i j c) = σ := by simp [sig, hc] + rw [hs] + apply inv_update z V h s σ σ i _ hI (fun _ _ => rfl) + · intro hiV + have hcV : c ≠ V := fun h' => hiV (h' ▸ hi) + have hcz : c = z := hc.resolve_right hcV + simp [atz j c hj hcz, ← notV i c hi hcV, atz i c hi hcz] + · intro hiz + have hcz : c = z := by rw [hi] at hiz; exact Option.some.inj hiz + simp [atz j c hj hcz] + · push Not at hc + have hs : sig z V h σ (.copy i j c) = Function.update σ i (σ j) := by simp [sig, hc] + rw [hs] + apply inv_update z V h s σ _ i _ hI (fun r hr => Function.update_of_ne hr _ _) + · intro _; simp [notV j c hj hc.2] + · intro hiz; rw [hi] at hiz; exact absurd (Option.some.inj hiz) hc.1 + +def start : St K Reg C := ⟨fun _ => 0, fun _ => none⟩ + +theorem inv_run : ∀ (s : St K Reg C) (σ : Reg → K) (evs : List (Ev K Reg C)), + Inv z V h s σ → Legal z V s evs → (∀ c, Ev.born h c ∈ evs → c ≠ z) → + Inv z V h (run s evs) (sigRun z V h σ evs) + | _, _, [], hI, _, _ => hI + | s, σ, e :: es, hI, ⟨hL, hLs⟩, hb => + inv_run (step s e) (sig z V h σ e) es + (inv_step z V h s σ e hI hL (fun c he => hb c (by simp [he]))) + hLs (fun c hc => hb c (by simp [hc])) + +/-- **T1 (hub blindness).** In a legal run from the empty state in which `h` is not born at the +hub z (h off-hub born), every register r not at V at the end has e_h-coefficient equal to the +interior program's value: hub ops never enter it. -/ +theorem T1_hub_blind (evs : List (Ev K Reg C)) (hL : Legal z V start evs) + (hb : ∀ c, Ev.born h c ∈ evs → c ≠ z) (r : Reg) (hr : (run start evs).loc r ≠ some V) : + (run start evs).row r h = sigRun z V h (fun _ => 0) (evs.filter fun e => ¬ hubOp z V e) r := by + have hI : Inv z V h (start : St K Reg C) (fun _ => 0) := + ⟨fun _ _ => rfl, fun r hr => by simp [start] at hr⟩ + rw [(inv_run z V h start _ evs hI hL hb).1 r hr, sigRun_filter] + +/-- **T1, two-run form.** Two legal runs with the same interior subsequence give every register +that is not at V at the end of both the same e_h-coefficient. -/ +theorem T1_two_runs (evs evs' : List (Ev K Reg C)) + (hL : Legal z V start evs) (hL' : Legal z V start evs') + (hb : ∀ c, Ev.born h c ∈ evs → c ≠ z) (hb' : ∀ c, Ev.born h c ∈ evs' → c ≠ z) + (hfil : evs.filter (fun e => ¬ hubOp z V e) = evs'.filter (fun e => ¬ hubOp z V e)) + (r : Reg) (hr : (run start evs).loc r ≠ some V) (hr' : (run start evs').loc r ≠ some V) : + (run start evs).row r h = (run start evs').row r h := by + rw [T1_hub_blind z V h evs hL hb r hr, T1_hub_blind z V h evs' hL' hb' r hr', hfil] + +/-! ## T2 difference lemma (direct carrier) + +y's row evolves only by: `addK a r` (y += a·row_k, with row_k's e_k-coefficient 1), `addO w` +(y += w with w's e_k-coefficient 0) and `scale u` (prose leaves SCALE of y unstated; it is allowed). +`recv` tracks the net receipt from k, `A` the accumulated e_k-coefficient. -/ + +inductive YOp (K Reg : Type*) + | addK (a : K) (r : Reg → K) + | addO (w : Reg → K) + | scale (u : K) + +/-- (y, receipt from k, effective coefficient sum). -/ +def yStep : (Reg → K) × (Reg → K) × K → YOp K Reg → (Reg → K) × (Reg → K) × K + | (y, R, A), .addK a r => (y + a • r, R + a • r, A + a) + | (y, R, A), .addO w => (y + w, R, A) + | (y, R, A), .scale u => (u • y, u • R, u * A) + +def yRun (st : (Reg → K) × (Reg → K) × K) : List (YOp K Reg) → (Reg → K) × (Reg → K) × K + | [] => st + | o :: os => yRun (yStep st o) os + +/-- Invariant of the y-replay: y's e_k-coefficient equals the accumulated coefficient A, and +R − A·r1 stays in any submodule N containing every (row_k at a contact) − r1. -/ +theorem T2_inv (k : Reg) (r1 : Reg → K) (N : Submodule K (Reg → K)) : + ∀ (ops : List (YOp K Reg)) (y R : Reg → K) (A : K), + (∀ a r, YOp.addK a r ∈ ops → r k = 1 ∧ r - r1 ∈ N) → (∀ w, YOp.addO w ∈ ops → w k = 0) → + y k = A → R - A • r1 ∈ N → + (yRun (y, R, A) ops).1 k = (yRun (y, R, A) ops).2.2 ∧ + (yRun (y, R, A) ops).2.1 - (yRun (y, R, A) ops).2.2 • r1 ∈ N + | [], _, _, _, _, _, hy, hR => ⟨hy, hR⟩ + | o :: os, y, R, A, hK, hO, hy, hR => by + have hK' : ∀ a r, YOp.addK a r ∈ os → r k = 1 ∧ r - r1 ∈ N := + fun a r h => hK a r (List.mem_cons_of_mem _ h) + have hO' : ∀ w, YOp.addO w ∈ os → w k = 0 := fun w h => hO w (List.mem_cons_of_mem _ h) + cases o with + | addK a r => + obtain ⟨hrk, hrN⟩ := hK a r List.mem_cons_self + apply T2_inv k r1 N os (y + a • r) (R + a • r) (A + a) hK' hO' + · simp [hy, hrk] + · have : R + a • r - (A + a) • r1 = (R - A • r1) + a • (r - r1) := by + rw [add_smul, smul_sub]; abel + rw [this]; exact N.add_mem hR (N.smul_mem a hrN) + | addO w => + have hwk := hO w List.mem_cons_self + apply T2_inv k r1 N os (y + w) R A hK' hO' + · simp [hy, hwk] + · exact hR + | scale u => + apply T2_inv k r1 N os (u • y) (u • R) (u * A) hK' hO' + · simp [hy] + · have : u • R - (u * A) • r1 = u • (R - A • r1) := by rw [smul_sub, mul_smul] + rw [this]; exact N.smul_mem u hR + +/-- **T2 (difference lemma, direct carrier).** y starts with e_k-coefficient 0 and its row changes +only through `ops`: contacts y += a·row_k(t) (row_k(t) has e_k-coefficient 1), additions of rows +free of e_k, and SCALEs of y. If y's final e_k-coefficient is 0 (its SPEC final row has no helper +coordinate; T1: no hub op can fix it), then +* the effective coefficients sum to 0, and +* the net receipt from k lies in span{row_k(t_i) − row_k(t_1)}: what k carried into its first + contact with y never reaches y net (any reference row r1, in particular row_k at the first contact). -/ +theorem T2_difference (k : Reg) (r1 : Reg → K) (ops : List (YOp K Reg)) (y0 : Reg → K) + (hy0 : y0 k = 0) + (hK : ∀ a r, YOp.addK a r ∈ ops → r k = 1) (hO : ∀ w, YOp.addO w ∈ ops → w k = 0) + (hfin : (yRun (y0, 0, 0) ops).1 k = 0) : + (yRun (y0, 0, 0) ops).2.2 = 0 ∧ + (yRun (y0, 0, 0) ops).2.1 ∈ + Submodule.span K {x | ∃ a r, YOp.addK a r ∈ ops ∧ x = r - r1} := by + set N := Submodule.span K {x | ∃ a r, YOp.addK a r ∈ ops ∧ x = r - r1} + have := T2_inv k r1 N ops y0 0 0 + (fun a r h => ⟨hK a r h, Submodule.subset_span ⟨a, r, h, rfl⟩⟩) hO hy0 (by simp) + have hA : (yRun (y0, 0, 0) ops).2.2 = 0 := by rw [← this.1, hfin] + refine ⟨hA, ?_⟩ + have h2 := this.2 + rwa [hA, zero_smul, sub_zero] at h2 + +/-- The receipt bookkeeping is faithful: the final row is y0 scaled, plus the receipt from k, plus +the other additions (scaled by later SCALEs). Here only the e_k-coordinate part matters, so we +record the coefficient identity: final e_k-coefficient = (Π scales)·y0_k + A. With y0_k = 0 this is A. -/ +theorem T2_coeff (k : Reg) : ∀ (ops : List (YOp K Reg)) (y R : Reg → K) (A : K), + (∀ a r, YOp.addK a r ∈ ops → r k = 1) → (∀ w, YOp.addO w ∈ ops → w k = 0) → + y k = A → (yRun (y, R, A) ops).1 k = (yRun (y, R, A) ops).2.2 := by + intro ops y R A hK hO hy + exact (T2_inv k 0 ⊤ ops y R A (fun a r h => ⟨hK a r h, Submodule.mem_top⟩) hO hy + Submodule.mem_top).1 + +/-! ## T2, corrected Σ statement + +The literal "Σ a_i = 0" is false once y is SCALEd between contacts (`T2_literal_false`). The +correct statement uses EFFECTIVE coefficients: contact i contributes a_i · Π(scales of y after it). +`scl ops` = product of all SCALE factors of y in `ops`; `contacts ops` = (effective coefficient, +row_k at the contact) for each contact, in order. -/ + +/-- product of the SCALE factors of y in `ops`. -/ +def scl : List (YOp K Reg) → K + | [] => 1 + | .scale u :: os => u * scl os + | .addK _ _ :: os => scl os + | .addO _ :: os => scl os + +/-- contacts with their effective coefficients a_i · Π(later scales). -/ +def contacts : List (YOp K Reg) → List (K × (Reg → K)) + | [] => [] + | .addK a r :: os => (a * scl os, r) :: contacts os + | .addO _ :: os => contacts os + | .scale _ :: os => contacts os + +/-- Closed form of the coefficient and receipt trackers. -/ +theorem yRun_closed : ∀ (ops : List (YOp K Reg)) (y R : Reg → K) (A : K), + (yRun (y, R, A) ops).2.2 = scl ops * A + ((contacts ops).map Prod.fst).sum ∧ + (yRun (y, R, A) ops).2.1 = scl ops • R + ((contacts ops).map (fun p => p.1 • p.2)).sum + | [], y, R, A => by simp [yRun, scl, contacts] + | o :: os, y, R, A => by + cases o with + | addK a r => + obtain ⟨h1, h2⟩ := yRun_closed os (y + a • r) (R + a • r) (A + a) + simp only [yRun, yStep, scl, contacts, List.map_cons, List.sum_cons] + refine ⟨by rw [h1]; ring, ?_⟩ + rw [h2, smul_add, smul_smul, mul_comm (scl os) a]; abel + | addO w => + obtain ⟨h1, h2⟩ := yRun_closed os (y + w) R A + simpa only [yRun, yStep, scl, contacts] using ⟨h1, h2⟩ + | scale u => + obtain ⟨h1, h2⟩ := yRun_closed os (u • y) (u • R) (u * A) + simp only [yRun, yStep, scl, contacts] + refine ⟨by rw [h1]; ring, ?_⟩ + rw [h2, smul_smul, mul_comm (scl os) u] + +/-- **T2, corrected.** Hypotheses as in `T2_difference`. Then +* Σ (effective coefficients a_i · Π later scales of y) = 0; +* the net receipt from k is Σ eff_i · row_k(t_i) = Σ eff_i · (row_k(t_i) − r1) for ANY r1, in + particular r1 = row_k(t_1): content k carried into its first contact never reaches y net. -/ +theorem T2_corrected (k : Reg) (ops : List (YOp K Reg)) (y0 : Reg → K) + (hy0 : y0 k = 0) + (hK : ∀ a r, YOp.addK a r ∈ ops → r k = 1) (hO : ∀ w, YOp.addO w ∈ ops → w k = 0) + (hfin : (yRun (y0, 0, 0) ops).1 k = 0) (r1 : Reg → K) : + ((contacts ops).map Prod.fst).sum = 0 ∧ + (yRun (y0, 0, 0) ops).2.1 = ((contacts ops).map (fun p => p.1 • p.2)).sum ∧ + (yRun (y0, 0, 0) ops).2.1 = ((contacts ops).map (fun p => p.1 • (p.2 - r1))).sum := by + obtain ⟨h1, h2⟩ := yRun_closed ops y0 0 0 + have hA := (T2_difference k r1 ops y0 hy0 hK hO hfin).1 + rw [h1, mul_zero, zero_add] at hA + have hrec : (yRun (y0, 0, 0) ops).2.1 = ((contacts ops).map (fun p => p.1 • p.2)).sum := by + rw [h2, smul_zero, zero_add] + refine ⟨hA, hrec, ?_⟩ + have hsplit : ∀ l : List (K × (Reg → K)), + (l.map (fun p => p.1 • (p.2 - r1))).sum + = (l.map (fun p => p.1 • p.2)).sum - (l.map Prod.fst).sum • r1 := by + intro l; induction l with + | nil => simp + | cons p l ih => + simp only [List.map_cons, List.sum_cons]; rw [ih, add_smul, smul_sub]; abel + rw [hsplit, hA, zero_smul, sub_zero, hrec] + +/-- Without SCALEs of y the effective coefficients are the literal a_i, so the prose "Σ a_i = 0" +holds verbatim. -/ +theorem contacts_noscale : ∀ (ops : List (YOp K Reg)), (∀ u, YOp.scale u ∉ ops) → + (contacts ops).map Prod.fst = ops.filterMap (fun o => match o with + | .addK a _ => some a | _ => none) + | [], _ => rfl + | o :: os, h => by + have h' : ∀ u, YOp.scale u ∉ os := fun u hu => h u (List.mem_cons_of_mem _ hu) + have hs : scl os = 1 := by + clear h; induction os with + | nil => rfl + | cons o' os' ih => + cases o' with + | scale u => exact absurd List.mem_cons_self (h' u) + | addK a r => exact ih (fun u hu => h' u (List.mem_cons_of_mem _ hu)) + | addO w => exact ih (fun u hu => h' u (List.mem_cons_of_mem _ hu)) + cases o with + | addK a r => simp [contacts, hs, contacts_noscale os h'] + | addO w => simpa [contacts] using contacts_noscale os h' + | scale u => exact absurd List.mem_cons_self (h u) + +/-- The finding, formal: y += k, y *= 2, y += (−2)·k. Final e_k-coefficient 0, literal Σ a = −1, +effective Σ = 1·2 + (−2) = 0. Over ℚ with one register. -/ +theorem T2_literal_false : + let ek : Unit → ℚ := fun _ => 1 + let ops : List (YOp ℚ Unit) := [.addK 1 ek, .scale 2, .addK (-2) ek] + (yRun ((0 : Unit → ℚ), 0, 0) ops).1 () = 0 ∧ (1 : ℚ) + (-2) ≠ 0 ∧ + ((contacts ops).map Prod.fst).sum = 0 := by + refine ⟨?_, by norm_num, ?_⟩ <;> simp [yRun, yStep, contacts, scl] + +end TokenCancel + +#print axioms TokenCancel.T1_hub_blind +#print axioms TokenCancel.T1_two_runs +#print axioms TokenCancel.T2_difference +#print axioms TokenCancel.T2_corrected +#print axioms TokenCancel.contacts_noscale +#print axioms TokenCancel.T2_literal_false diff --git a/research/p104-tiered-ceiling/lean/Nov15/TokenCancel.md b/research/p104-tiered-ceiling/lean/Nov15/TokenCancel.md new file mode 100644 index 0000000000..06a05563e7 --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/TokenCancel.md @@ -0,0 +1,36 @@ +# TokenCancel.lean: BIG-TOKENCANCEL T1 (hub blindness) + T2 (difference lemma). No sorry, ~6 s, 1.7 GB RSS +Source: internal notes (not included). Axioms (3 printed): [propext, Quot.sound]. + +**Model.** +- Registers Reg, charts C, hubs z (= {0}) and V. Rows are in initial-row coordinates. +- Events: born (row e_i), init (row 0), move, add i += a·j (i ≠ j), scale, clear, copy. Each event carries its chart. +- Legal = births/INITs of absent registers and co-presence at the event's chart, plus the two [C] facts of T1(a)/(b): no MOVE enters z, and no MOVE leaves V (0 of 6,257 on #7623). +- `hubOp` = an add/scale/clear/copy at z or V. + +**T1.** +- `sigRun` is the interior coefficient program: it tracks the e_h-coefficient and ignores hub ops. `sigRun_filter` shows it depends only on the non-hub-op subsequence. +- `T1_hub_blind`: in a legal run where h is not born at z (h off-hub born), every register not at V at the end has row[h] = sigRun on the interior subsequence. +- `T1_two_runs`: two legal runs with the same interior subsequence agree on the e_h-coefficient of every register that is off V at the end of both. +- Proof invariant: rows not at V carry the program's value; rows at z carry 0. +- The hypothesis z ≠ V is NOT needed. T1' (the joint-hub D-mix corollary) is plain invertibility and is not formalized. + +**T2.** +- y's row changes only through `addK a r` (contact y += a·row_k, with r_k = 1), `addO w` (w_k = 0) and `scale u` of y. +- `T2_difference`: if y₀_k = 0 and y's final e_k-coefficient is 0, then + - the effective coefficient sum is 0; + - the net receipt from k lies in span{r_i − r1} for ANY reference row r1, in particular row_k at the first contact. So content k carried into the first contact never reaches y net. +- `T2_coeff`: final e_k-coefficient = A. + +**Finding (scope, T2).** The literal "Σ a_i = 0" is FALSE if y is SCALEd between contacts. Example: y += k, y *= 2, y += (−2)·k gives Σ a = −1, yet y_k = 0. +- Minimal fix: use effective coefficients a_i·Π(later scales of y), or require that y is not SCALEd between contacts. +- The conclusion (receipt ∈ span of post-first-contact differences) survives SCALE. +- CLEAR/COPY of y and relays through third registers remain outside scope, as the prose says. + +**T2 corrected .** Same file, axioms [propext, Quot.sound] (the counterexample also uses Classical.choice). +- `contacts ops` lists (a_i · Π(later scales of y), row_k(t_i)) for each contact. +- `yRun_closed` gives the closed forms of the coefficient and receipt trackers. +- `T2_corrected`: under T2's hypotheses, + - Σ effective coefficients = 0; + - the net receipt = Σ eff_i · row_k(t_i) = Σ eff_i · (row_k(t_i) − r1) for ANY r1 (take r1 = row_k(t_1)). +- `contacts_noscale`: without SCALEs of y, eff_i = a_i, so the literal prose "Σ a_i = 0" holds. +- `T2_literal_false`: the finding, formal over ℚ. y += k, y *= 2, y += (−2)k gives final y_k = 0 and Σ a = −1, while effective Σ = 0. diff --git a/research/p104-tiered-ceiling/lean/Nov15/WholeFloorCover.lean b/research/p104-tiered-ceiling/lean/Nov15/WholeFloorCover.lean new file mode 100644 index 0000000000..7c04dd9336 --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/WholeFloorCover.lean @@ -0,0 +1,24 @@ +import Nov15.WholeFloorCoverData +import Nov15.JointCeiling + +/-! WholeFloorCover : the cover F < 0 on [.0204110964, 1] for (caller 6 7) + 17 * natFloor; data in WholeFloorCoverData. -/ +namespace WholeFloorCover +open NumCertK JointCeiling CallerCost + +theorem invoice_eq_Fc (s : ℝ) : Finv s (invoice (caller 6 7) natFloor 17) = Fc cfW s := by + simp only [Finv, Fh, invoice, caller, callerT, callerP, armT, armP, natFloor, scale, Fc, cfW, + List.range_succ, List.range_zero] + norm_num + ring + +/-- **the cover**: F < 0 on [.0204110964, 1] (t = 1 - s) for the floor-native invoice. -/ +theorem cover (t : ℝ) (ht : (204110965 : ℝ) / 10 ^ 10 ≤ t) (ht1 : t ≤ 1) : + Finv (1 - t) (invoice (caller 6 7) natFloor 17) < 0 := by + rw [invoice_eq_Fc] + apply cfW_neg _ (by linarith) + push_cast + linarith + +end WholeFloorCover + +#print axioms WholeFloorCover.cover diff --git a/research/p104-tiered-ceiling/lean/Nov15/WholeFloorCoverData.lean b/research/p104-tiered-ceiling/lean/Nov15/WholeFloorCoverData.lean new file mode 100644 index 0000000000..8d59602eab --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/WholeFloorCoverData.lean @@ -0,0 +1,47 @@ +import Nov15.WholeFloorCoverData1 + +namespace WholeFloorCover +open NumCertK + +theorem cfW_p6 : Fup cfW (763/1000) (163/200) < 0 := by decide +kernel +theorem cfW_p7 : Fup cfW (163/200) (851/1000) < 0 := by decide +kernel +theorem cfW_p8 : Fup cfW (851/1000) (879/1000) < 0 := by decide +kernel +theorem cfW_p9 : Fup cfW (879/1000) (901/1000) < 0 := by decide +kernel +theorem cfW_p10 : Fup cfW (901/1000) (459/500) < 0 := by decide +kernel +theorem cfW_p11 : Fup cfW (459/500) (93/100) < 0 := by decide +kernel +theorem cfW_d : 0 < dLo cfW (93/100) (9795889035/10^10) := by decide +kernel +theorem cfW_end : Fup cfW (9795889035/10^10) (9795889035/10^10) < 0 := by decide +kernel + +theorem cfW_neg (s : ℝ) (h0 : 0 ≤ s) (hs : s ≤ ((9795889035 / 10 ^ 10 : ℚ) : ℝ)) : Fc cfW s < 0 := by + have o := cfW_ok + by_cases a1 : s ≤ (((73/250) : ℚ) : ℝ) + · exact Fc_neg_piece cfW o 0 (73/250) (le_refl _) (by norm_num) cfW_p1 s (by simpa using h0) a1 + by_cases a2 : s ≤ (((59/125) : ℚ) : ℝ) + · exact Fc_neg_piece cfW o (73/250) (59/125) (by norm_num) (by norm_num) cfW_p2 s (by push_neg at a1; exact a1.le) a2 + by_cases a3 : s ≤ (((301/500) : ℚ) : ℝ) + · exact Fc_neg_piece cfW o (59/125) (301/500) (by norm_num) (by norm_num) cfW_p3 s (by push_neg at a2; exact a2.le) a3 + by_cases a4 : s ≤ (((87/125) : ℚ) : ℝ) + · exact Fc_neg_piece cfW o (301/500) (87/125) (by norm_num) (by norm_num) cfW_p4 s (by push_neg at a3; exact a3.le) a4 + by_cases a5 : s ≤ (((763/1000) : ℚ) : ℝ) + · exact Fc_neg_piece cfW o (87/125) (763/1000) (by norm_num) (by norm_num) cfW_p5 s (by push_neg at a4; exact a4.le) a5 + by_cases a6 : s ≤ (((163/200) : ℚ) : ℝ) + · exact Fc_neg_piece cfW o (763/1000) (163/200) (by norm_num) (by norm_num) cfW_p6 s (by push_neg at a5; exact a5.le) a6 + by_cases a7 : s ≤ (((851/1000) : ℚ) : ℝ) + · exact Fc_neg_piece cfW o (163/200) (851/1000) (by norm_num) (by norm_num) cfW_p7 s (by push_neg at a6; exact a6.le) a7 + by_cases a8 : s ≤ (((879/1000) : ℚ) : ℝ) + · exact Fc_neg_piece cfW o (851/1000) (879/1000) (by norm_num) (by norm_num) cfW_p8 s (by push_neg at a7; exact a7.le) a8 + by_cases a9 : s ≤ (((901/1000) : ℚ) : ℝ) + · exact Fc_neg_piece cfW o (879/1000) (901/1000) (by norm_num) (by norm_num) cfW_p9 s (by push_neg at a8; exact a8.le) a9 + by_cases a10 : s ≤ (((459/500) : ℚ) : ℝ) + · exact Fc_neg_piece cfW o (901/1000) (459/500) (by norm_num) (by norm_num) cfW_p10 s (by push_neg at a9; exact a9.le) a10 + by_cases a11 : s ≤ (((93/100) : ℚ) : ℝ) + · exact Fc_neg_piece cfW o (459/500) (93/100) (by norm_num) (by norm_num) cfW_p11 s (by push_neg at a10; exact a10.le) a11 + have h1 := Fc_mono cfW o (93/100) (9795889035/10^10) (by norm_num) (by norm_num) cfW_d s + (by push_neg at a11; exact a11.le) hs + have h2 := Fc_neg_piece cfW o (9795889035/10^10) (9795889035/10^10) (by norm_num) (by norm_num) cfW_end + ((9795889035/10^10 : ℚ) : ℝ) (le_refl _) (le_refl _) + linarith + +end WholeFloorCover + +#print axioms WholeFloorCover.cfW_neg diff --git a/research/p104-tiered-ceiling/lean/Nov15/WholeFloorCoverData1.lean b/research/p104-tiered-ceiling/lean/Nov15/WholeFloorCoverData1.lean new file mode 100644 index 0000000000..097aac7ee4 --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/WholeFloorCoverData1.lean @@ -0,0 +1,23 @@ +import Nov15.NumCertK + +/-! +WholeFloorCoverData1 : discharges the interval-cover hypothesis of WholeFloorNest.kappa_whole_floor_nested +with kernel interval library (NumCertK): the fixed #7113 caller C(8|9) = caller 6 7 at 17 calls on the +floor native `natFloor` has F(s) < 0 for every s in [0, 1 - .0204110964]. Kernel only; no native_decide. +-/ +namespace WholeFloorCover +open NumCertK + +/-- F of (caller 6 7) + 17 * natFloor, merged by rank. -/ +def cfW : CF := [(1, -3648), (2, 1496), (8, -7456), (9, 384), + (16, -416), (17, 416), (24, -416), (25, 416), (32, -416), (33, 416), (40, -416), (41, 416), (48, -416), + (49, 416), (56, -416), (57, 416), (64, -208), (65, 416), (73, 208), (137, 208)] + +theorem cfW_ok : okR cfW := by decide +kernel +theorem cfW_p1 : Fup cfW 0 (73/250) < 0 := by decide +kernel +theorem cfW_p2 : Fup cfW (73/250) (59/125) < 0 := by decide +kernel +theorem cfW_p3 : Fup cfW (59/125) (301/500) < 0 := by decide +kernel +theorem cfW_p4 : Fup cfW (301/500) (87/125) < 0 := by decide +kernel +theorem cfW_p5 : Fup cfW (87/125) (763/1000) < 0 := by decide +kernel + +end WholeFloorCover diff --git a/research/p104-tiered-ceiling/lean/Nov15/WordDuality.lean b/research/p104-tiered-ceiling/lean/Nov15/WordDuality.lean new file mode 100644 index 0000000000..166ddb4d93 --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/WordDuality.lean @@ -0,0 +1,451 @@ +/- +WordDuality . See WordDuality.md. Source: internal notes + +D = sigma . perp . time-reversal . transpose. +Model: charts `C` with an involution `perp` (dim (perp c) = N - dim c, perp z = V), registers `Reg`, a word = initial chart of every +register + a list of events (MOVE a->b, ADD, SCALE, COPY, INIT, CLEAR). Legality = co-presence + hub rules (no MOVE leaves V, +none enters z) + a move relation R (ascent / owned descent) closed under (a,b) -> (perp b, perp a). + Part 1 legal words go to legal words, boundaries swap (`dual_run`). + Part 2 matrices (ADD / SCALE / MOVE): M(D l) = sigma-relabel of (M l)^T (`Mrec_dual`). + Part 3 invoice: helper (b,e,steps) -> (N-e, N-b, reversed swapped steps); Theorem K invoice (FibreK) unchanged (`dualH_invoice`). + Part 4 P104 boundary data under sigma: X_p, Y_p exchange (`selfdual_boundary`); 2x2 contract blocks (`hosted_block`, `nonhosted_block`). + Part 5 caveat: COPY does not dualise to an ADD at matrix level (`copy_not_add`). +Kernel only. +-/ +import Nov15.FibreK +import Mathlib.Data.Matrix.Basis +import Mathlib.Data.Matrix.Mul + +set_option linter.unusedSectionVars false +set_option linter.unusedVariables false + +namespace WordDuality +open FibreK CallerCost Matrix + +structure Charts (C : Type*) (N : ℕ) where + perp : C → C + perp_perp : ∀ c, perp (perp c) = c + dim : C → ℕ + dim_le : ∀ c, dim c ≤ N + dim_perp : ∀ c, dim (perp c) = N - dim c + z : C + V : C + perp_z : perp z = V + +namespace Charts +variable {C : Type*} {N : ℕ} (X : Charts C N) +theorem perp_V : X.perp X.V = X.z := by rw [← X.perp_z, X.perp_perp] +theorem ne_V_perp {a : C} (h : a ≠ X.V) : X.perp a ≠ X.z := by + intro h'; apply h; rw [← X.perp_perp a, h', X.perp_z] +theorem ne_z_perp {b : C} (h : b ≠ X.z) : X.perp b ≠ X.V := by + intro h'; apply h; rw [← X.perp_perp b, h', X.perp_V] +end Charts + +inductive Ev (K Reg C : Type*) + | move (i : Reg) (a b : C) + | add (i j : Reg) (q : K) (c : C) + | scale (i : Reg) (u : K) (c : C) + | copy (i j : Reg) (c : C) + | init (i : Reg) (c : C) + | clear (i : Reg) (c : C) + +variable {K Reg C : Type*} {N : ℕ} + +section Words +variable [DecidableEq Reg] + +def stepL (ℓ : Reg → C) : Ev K Reg C → (Reg → C) + | .move i _ b => Function.update ℓ i b + | _ => ℓ + +def runL (ℓ : Reg → C) : List (Ev K Reg C) → (Reg → C) + | [] => ℓ + | e :: es => runL (stepL ℓ e) es + +theorem runL_append (ℓ : Reg → C) (l1 l2 : List (Ev K Reg C)) : + runL ℓ (l1 ++ l2) = runL (runL ℓ l1) l2 := by + induction l1 generalizing ℓ with + | nil => rfl + | cons e es ih => simp [runL, ih] + +def LegalEv (X : Charts C N) (R : C → C → Prop) (ℓ : Reg → C) : Ev K Reg C → Prop + | .move i a b => ℓ i = a ∧ a ≠ X.V ∧ b ≠ X.z ∧ R a b + | .add i j _ c => i ≠ j ∧ ℓ i = c ∧ ℓ j = c + | .scale i _ c => ℓ i = c + | .copy i j c => i ≠ j ∧ ℓ i = c ∧ ℓ j = c + | .init i c => ℓ i = c + | .clear i c => ℓ i = c + +def LegalL (X : Charts C N) (R : C → C → Prop) : (Reg → C) → List (Ev K Reg C) → Prop + | _, [] => True + | ℓ, e :: es => LegalEv X R ℓ e ∧ LegalL X R (stepL ℓ e) es + +theorem LegalL_append (X : Charts C N) (R : C → C → Prop) (ℓ : Reg → C) (l1 l2 : List (Ev K Reg C)) : + LegalL X R ℓ (l1 ++ l2) ↔ LegalL X R ℓ l1 ∧ LegalL X R (runL ℓ l1) l2 := by + induction l1 generalizing ℓ with + | nil => simp [LegalL, runL] + | cons e es ih => simp [LegalL, runL, ih, and_assoc] + +variable [One K] + +/-- the dual of one event. COPY becomes ADD (valid on a clean target only; see `copy_not_add`). -/ +def dualEv (X : Charts C N) (σ : Reg ≃ Reg) : Ev K Reg C → Ev K Reg C + | .move i a b => .move (σ i) (X.perp b) (X.perp a) + | .add i j q c => .add (σ j) (σ i) q (X.perp c) + | .scale i u c => .scale (σ i) u (X.perp c) + | .copy i j c => .add (σ j) (σ i) 1 (X.perp c) + | .init i c => .clear (σ i) (X.perp c) + | .clear i c => .init (σ i) (X.perp c) + +/-- time reversal of the dualised events. -/ +def dualList (X : Charts C N) (σ : Reg ≃ Reg) (l : List (Ev K Reg C)) : List (Ev K Reg C) := + (l.map (dualEv X σ)).reverse + +theorem dualList_cons (X : Charts C N) (σ : Reg ≃ Reg) (e : Ev K Reg C) (l : List (Ev K Reg C)) : + dualList X σ (e :: l) = dualList X σ l ++ [dualEv X σ e] := by + simp [dualList] + +/-- PART 1. A legal word dualises to a legal word; the dual starts at perp of the final charts and ends at perp of the initial +charts (births and ends exchange). -/ +theorem dual_run (X : Charts C N) (R : C → C → Prop) (hR : ∀ a b, R a b → R (X.perp b) (X.perp a)) + (σ : Reg ≃ Reg) : + ∀ (l : List (Ev K Reg C)) (ℓ : Reg → C), LegalL X R ℓ l → + runL (fun r => X.perp (runL ℓ l (σ.symm r))) (dualList X σ l) = (fun r => X.perp (ℓ (σ.symm r))) ∧ + LegalL X R (fun r => X.perp (runL ℓ l (σ.symm r))) (dualList X σ l) := by + intro l + induction l with + | nil => intro ℓ _; exact ⟨rfl, trivial⟩ + | cons e es ih => + intro ℓ h + obtain ⟨he, hes⟩ := h + obtain ⟨A, B⟩ := ih (stepL ℓ e) hes + have hS : (fun r => X.perp (runL ℓ (e :: es) (σ.symm r))) = + (fun r => X.perp (runL (stepL ℓ e) es (σ.symm r))) := rfl + rw [hS, dualList_cons, runL_append, LegalL_append, A] + -- the last event + cases e with + | move i a b => + obtain ⟨h1, h2, h3, h4⟩ := he + subst h1 + refine ⟨?_, B, ?_⟩ + · simp only [runL, dualEv, stepL] + funext r + by_cases hr : r = σ i + · subst hr; simp + · have : σ.symm r ≠ i := by + intro h; apply hr; rw [← h]; simp + simp [Function.update_of_ne hr, Function.update_of_ne this] + · exact ⟨⟨by simp [stepL], X.ne_z_perp h3, X.ne_V_perp h2, hR _ _ h4⟩, trivial⟩ + | add i j q c => + obtain ⟨h1, h2, h3⟩ := he + refine ⟨?_, B, ?_⟩ + · simp [runL, dualEv, stepL] + · simp [LegalL, LegalEv, runL, dualEv, stepL, A, h2, h3] + exact fun h => h1 h.symm + | scale i u c => + refine ⟨?_, B, ?_⟩ + · simp [runL, dualEv, stepL] + · simp [LegalL, LegalEv, runL, dualEv, stepL, A]; simp [LegalEv] at he; simp [he] + | copy i j c => + obtain ⟨h1, h2, h3⟩ := he + refine ⟨?_, B, ?_⟩ + · simp [runL, dualEv, stepL] + · simp [LegalL, LegalEv, runL, dualEv, stepL, A, h2, h3] + exact fun h => h1 h.symm + | init i c => + refine ⟨?_, B, ?_⟩ + · simp [runL, dualEv, stepL] + · simp [LegalL, LegalEv, runL, dualEv, stepL, A]; simp [LegalEv] at he; simp [he] + | clear i c => + refine ⟨?_, B, ?_⟩ + · simp [runL, dualEv, stepL] + · simp [LegalL, LegalEv, runL, dualEv, stepL, A]; simp [LegalEv] at he; simp [he] + +/-- ascent and descent both survive: (a,b) ascending (dim a ≤ dim b) gives (perp b, perp a) ascending. -/ +theorem ascent_dual (X : Charts C N) : ∀ a b, X.dim a ≤ X.dim b → X.dim (X.perp b) ≤ X.dim (X.perp a) := by + intro a b h; rw [X.dim_perp, X.dim_perp]; have := X.dim_le a; have := X.dim_le b; omega + +theorem descent_dual (X : Charts C N) : ∀ a b, X.dim b ≤ X.dim a → X.dim (X.perp b) ≥ X.dim (X.perp a) := by + intro a b h; rw [X.dim_perp, X.dim_perp]; have := X.dim_le a; have := X.dim_le b; omega + +/-! ### words, boundaries -/ + +structure Word (K Reg C : Type*) where + init0 : Reg → C + evs : List (Ev K Reg C) + +def Word.fin (w : Word K Reg C) : Reg → C := runL w.init0 w.evs + +def dualWord (X : Charts C N) (σ : Reg ≃ Reg) (w : Word K Reg C) : Word K Reg C := + ⟨fun r => X.perp (w.fin (σ.symm r)), dualList X σ w.evs⟩ + +theorem dual_legal (X : Charts C N) (R : C → C → Prop) (hR : ∀ a b, R a b → R (X.perp b) (X.perp a)) + (σ : Reg ≃ Reg) (w : Word K Reg C) (h : LegalL X R w.init0 w.evs) : + LegalL X R (dualWord X σ w).init0 (dualWord X σ w).evs := (dual_run X R hR σ w.evs w.init0 h).2 + +/-- births of the dual are perp of the ends; ends of the dual are perp of the births. -/ +theorem dual_boundary (X : Charts C N) (R : C → C → Prop) (hR : ∀ a b, R a b → R (X.perp b) (X.perp a)) + (σ : Reg ≃ Reg) (w : Word K Reg C) (h : LegalL X R w.init0 w.evs) (r : Reg) : + (dualWord X σ w).init0 (σ r) = X.perp (w.fin r) ∧ (dualWord X σ w).fin (σ r) = X.perp (w.init0 r) := by + constructor + · simp [dualWord] + · have := congrFun (dual_run X R hR σ w.evs w.init0 h).1 (σ r) + simpa [Word.fin, dualWord] using this + +theorem dual_dim_boundary (X : Charts C N) (R : C → C → Prop) (hR : ∀ a b, R a b → R (X.perp b) (X.perp a)) + (σ : Reg ≃ Reg) (w : Word K Reg C) (h : LegalL X R w.init0 w.evs) (r : Reg) : + X.dim ((dualWord X σ w).init0 (σ r)) = N - X.dim (w.fin r) ∧ + X.dim ((dualWord X σ w).fin (σ r)) = N - X.dim (w.init0 r) := by + obtain ⟨a, b⟩ := dual_boundary X R hR σ w h r + rw [a, b, X.dim_perp, X.dim_perp]; exact ⟨rfl, rfl⟩ + +end Words + +/-! ### Part 2: matrices -/ +section Mat +variable [Fintype Reg] [DecidableEq Reg] [CommRing K] + +def evMat : Ev K Reg C → Matrix Reg Reg K + | .add i j q _ => 1 + Matrix.single i j q + | .scale i u _ => Matrix.diagonal (Function.update (1 : Reg → K) i u) + | _ => 1 + +/-- events with a matrix semantics (MOVE only changes location). -/ +def Lin : Ev K Reg C → Prop + | .move .. => True + | .add .. => True + | .scale .. => True + | _ => False + +/-- total matrix of a word in initial-row coordinates: later events multiply on the left. -/ +def Mrec : List (Ev K Reg C) → Matrix Reg Reg K + | [] => 1 + | e :: es => Mrec es * evMat e + +theorem Mrec_append (l1 l2 : List (Ev K Reg C)) : Mrec (l1 ++ l2) = Mrec l2 * Mrec l1 := by + induction l1 with + | nil => simp [Mrec] + | cons e es ih => simp [Mrec, ih, Matrix.mul_assoc] + +theorem evMat_dual (X : Charts C N) (σ : Reg ≃ Reg) (e : Ev K Reg C) (he : Lin e) : + evMat (dualEv X σ e) = (evMat e)ᵀ.submatrix σ.symm σ.symm := by + cases e with + | move i a b => simp [evMat, dualEv] + | add i j q c => + ext a b + simp [evMat, dualEv, Matrix.single_apply, Matrix.one_apply, Matrix.transpose_apply, Matrix.submatrix_apply, Equiv.eq_symm_apply] + | scale i u c => + ext a b + simp [evMat, dualEv, Matrix.diagonal_apply, Function.update_apply, Equiv.symm_apply_eq] + | copy _ _ _ => exact absurd he (by simp [Lin]) + | init _ _ => exact absurd he (by simp [Lin]) + | clear _ _ => exact absurd he (by simp [Lin]) + +/-- PART 2. M(D l) is the sigma-relabel of the transpose of M(l). -/ +theorem Mrec_dual (X : Charts C N) (σ : Reg ≃ Reg) : + ∀ l : List (Ev K Reg C), (∀ e ∈ l, Lin e) → Mrec (dualList X σ l) = (Mrec l)ᵀ.submatrix σ.symm σ.symm := by + intro l + induction l with + | nil => intro _; simp [dualList, Mrec] + | cons e es ih => + intro h + have he := h e (by simp) + have hes := ih (fun x hx => h x (by simp [hx])) + rw [dualList_cons, Mrec_append, hes] + simp only [Mrec, Matrix.one_mul, Matrix.transpose_mul] + rw [evMat_dual X σ e he, Matrix.submatrix_mul_equiv] + +end Mat + +/-! ### Part 3: the Theorem-K invoice is unchanged -/ +section Invoice +variable [DecidableEq Reg] + +/-- the MOVE steps (source dim, target dim) of register `r`. -/ +def regSteps (X : Charts C N) (r : Reg) (l : List (Ev K Reg C)) : List (ℕ × ℕ) := + l.filterMap fun e => match e with + | .move i a b => if i = r then some (X.dim a, X.dim b) else none + | _ => none + +def swapN (N : ℕ) (s : ℕ × ℕ) : ℕ × ℕ := (N - s.2, N - s.1) + +/-- register `r` as a FibreK helper: birth dim, end dim, steps. -/ +def helperOf (X : Charts C N) (w : Word K Reg C) (r : Reg) : Helper := + ⟨X.dim (w.init0 r), X.dim (w.fin r), regSteps X r w.evs⟩ + +/-- a helper b -> e becomes (N-e) -> (N-b), with reversed swapped steps. -/ +def dualH (N : ℕ) (h : Helper) : Helper := ⟨N - h.e, N - h.b, (h.steps.map (swapN N)).reverse⟩ + +variable [One K] + +theorem regSteps_dual (X : Charts C N) (σ : Reg ≃ Reg) (r : Reg) : + ∀ l : List (Ev K Reg C), regSteps X (σ r) (dualList X σ l) = ((regSteps X r l).map (swapN N)).reverse := by + intro l + induction l with + | nil => simp [dualList, regSteps] + | cons e es ih => + rw [dualList_cons] + have : regSteps X (σ r) (dualList X σ es ++ [dualEv X σ e]) = + regSteps X (σ r) (dualList X σ es) ++ regSteps X (σ r) [dualEv X σ e] := by + simp [regSteps, List.filterMap_append] + rw [this, ih] + cases e with + | move i a b => + by_cases h : i = r + · subst h; simp [regSteps, dualEv, swapN, X.dim_perp] + · simp [regSteps, dualEv, h] + | add i j q c => simp [regSteps, dualEv] + | scale i u c => simp [regSteps, dualEv] + | copy i j c => simp [regSteps, dualEv] + | init i c => simp [regSteps, dualEv] + | clear i c => simp [regSteps, dualEv] + +/-- PART 3a. The dual word's register `sigma r` is the dual helper of `r` (b,e) -> (N-e, N-b). -/ +theorem helperOf_dual (X : Charts C N) (R : C → C → Prop) (hR : ∀ a b, R a b → R (X.perp b) (X.perp a)) + (σ : Reg ≃ Reg) (w : Word K Reg C) (h : LegalL X R w.init0 w.evs) (r : Reg) : + helperOf X (dualWord X σ w) (σ r) = dualH N (helperOf X w r) := by + obtain ⟨b1, b2⟩ := dual_dim_boundary X R hR σ w h r + simp only [helperOf, dualH, dualWord, b1, b2] + simp only [dualWord] at b1 b2 + rw [b1, b2] + simp [regSteps_dual X σ r] + +theorem gap_swapN (N : ℕ) (s : ℕ × ℕ) (h1 : s.1 ≤ N) (h2 : s.2 ≤ N) : gap (swapN N s) = gap s := by + simp only [gap, swapN]; omega + +/-- PART 3b. Dualising a helper list leaves FibreK's invoice (Theorem K) unchanged: +births/ends (b,e) -> (N-e,N-b) keep the climb, every MOVE keeps its |Δdim|. -/ +theorem dualH_invoice (E : Inv) (tb : Table) (H : List Helper) + (hN : ∀ h ∈ H, h.b ≤ h.e ∧ h.e ≤ N ∧ ∀ s ∈ h.steps, s.1 ≤ N ∧ s.2 ≤ N) (t : ℝ) : + Fi (nativeInv E tb (H.map (dualH N))) t = Fi (nativeInv E tb H) t := by + rw [K_word, K_word] + unfold FK + have hP : PiW (H.map (dualH N)) = PiW H := by + unfold PiW + congr 1 + rw [List.map_map] + apply List.map_congr_left + intro h hh + obtain ⟨a, b, _⟩ := hN h hh + simp only [Function.comp, dualH]; omega + have hS : (((Ssum (H.map (dualH N))).map fun s => Fh (tb.tP (gap s)) t).sum) = + ((Ssum H).map fun s => Fh (tb.tP (gap s)) t).sum := by + simp only [Ssum, Multiset.map_coe, Multiset.sum_coe] + rw [sum_flatMap_map, sum_flatMap_map, List.map_map] + congr 1 + apply List.map_congr_left + intro h hh + obtain ⟨_, _, c⟩ := hN h hh + simp only [Function.comp, dualH, List.map_reverse, List.sum_reverse, List.map_map] + congr 1 + apply List.map_congr_left + intro s hs + obtain ⟨c1, c2⟩ := c s hs + simp only [Function.comp, gap_swapN N s c1 c2] + rw [hP, hS] + +theorem dualH_root (c E : Inv) (tb : Table) (H : List Helper) (L : ℕ) + (hN : ∀ h ∈ H, h.b ≤ h.e ∧ h.e ≤ N ∧ ∀ s ∈ h.steps, s.1 ≤ N ∧ s.2 ≤ N) (κ : ℝ) : + IsRoot (Fi (invoice c (nativeInv E tb (H.map (dualH N))) L)) κ ↔ + IsRoot (Fi (invoice c (nativeInv E tb H) L)) κ := by + unfold IsRoot + rw [Fi_invoice, Fi_invoice, dualH_invoice E tb H hN κ] + +/-- PART 3c, word level: the helpers of `D w` (registers `sigma r`) have the same invoice as those of `w`. +Hypothesis: the listed registers climb (birth dim <= end dim), as helpers do. -/ +theorem word_invoice (X : Charts C N) (R : C → C → Prop) (hR : ∀ a b, R a b → R (X.perp b) (X.perp a)) + (σ : Reg ≃ Reg) (w : Word K Reg C) (h : LegalL X R w.init0 w.evs) (rs : List Reg) + (hc : ∀ r ∈ rs, X.dim (w.init0 r) ≤ X.dim (w.fin r)) (E : Inv) (tb : Table) (t : ℝ) : + Fi (nativeInv E tb ((rs.map σ).map (helperOf X (dualWord X σ w)))) t = + Fi (nativeInv E tb (rs.map (helperOf X w))) t := by + have : (rs.map σ).map (helperOf X (dualWord X σ w)) = (rs.map (helperOf X w)).map (dualH N) := by + rw [List.map_map, List.map_map] + apply List.map_congr_left + intro r _ + exact helperOf_dual X R hR σ w h r + rw [this] + apply dualH_invoice + intro h' hh' + obtain ⟨r, hr, rfl⟩ := List.mem_map.mp hh' + refine ⟨hc r hr, X.dim_le _, ?_⟩ + intro s hs + simp only [helperOf, regSteps, List.mem_filterMap] at hs + obtain ⟨e, _, he⟩ := hs + cases e <;> simp at he + obtain ⟨_, rfl⟩ := he + exact ⟨X.dim_le _, X.dim_le _⟩ + +end Invoice + +/-! ### Part 4: P104 boundary data -/ +section P104 +variable [DecidableEq Reg] [One K] {ι : Type*} + +/-- hypotheses (from DU1 section 1): X_p runs

-> V, Y_p runs {0} -> p^perp, sigma swaps X_p, Y_p, perp

= p^perp. +The dual word has the same register boundaries (g = id): the problem is self-dual. -/ +theorem selfdual_boundary (X : Charts C N) (R : C → C → Prop) (hR : ∀ a b, R a b → R (X.perp b) (X.perp a)) + (σ : Reg ≃ Reg) (w : Word K Reg C) (h : LegalL X R w.init0 w.evs) + (Xr Yr : ι → Reg) (line hyp : ι → C) + (hσX : ∀ p, σ (Xr p) = Yr p) (hσY : ∀ p, σ (Yr p) = Xr p) (hperp : ∀ p, X.perp (line p) = hyp p) + (hX : ∀ p, w.init0 (Xr p) = line p ∧ w.fin (Xr p) = X.V) + (hY : ∀ p, w.init0 (Yr p) = X.z ∧ w.fin (Yr p) = hyp p) (p : ι) : + ((dualWord X σ w).init0 (Xr p) = line p ∧ (dualWord X σ w).fin (Xr p) = X.V) ∧ + ((dualWord X σ w).init0 (Yr p) = X.z ∧ (dualWord X σ w).fin (Yr p) = hyp p) := by + have hl : ∀ p, X.perp (hyp p) = line p := fun p => by rw [← hperp, X.perp_perp] + obtain ⟨a1, a2⟩ := dual_boundary X R hR σ w h (Yr p) + obtain ⟨b1, b2⟩ := dual_boundary X R hR σ w h (Xr p) + rw [hσY] at a1 a2 + rw [hσX] at b1 b2 + refine ⟨⟨?_, ?_⟩, ⟨?_, ?_⟩⟩ + · rw [a1, (hY p).2, hl] + · rw [a2, (hY p).1, X.perp_z] + · rw [b1, (hX p).2, X.perp_V] + · rw [b2, (hX p).1, hperp] + +end P104 + +/-! ### contract blocks (from DU1.md; the non-hosted block is reconstructed from the card's dual [[1/2,-1],[1/2,1]]) -/ +section Blocks +def sw : Equiv.Perm (Fin 2) := Equiv.swap 0 1 + +/-- hosted block [[1,0],[1,1]] is invariant under transpose + sigma. -/ +theorem hosted_block : + (!![1, 0; 1, 1] : Matrix (Fin 2) (Fin 2) ℚ)ᵀ.submatrix sw.symm sw.symm = !![1, 0; 1, 1] := by + ext i j; fin_cases i <;> fin_cases j <;> simp [sw, Equiv.swap_apply_def] + +/-- non-hosted block F = [[1,-1],[1/2,1/2]]: D(F) = [[1/2,-1],[1/2,1]] and diag(1,1/2) D(F) diag(2,1) = F +(one SCALE 2 and one SCALE 1/2, unpriced). -/ +theorem nonhosted_block : + (!![1, -1; 1/2, 1/2] : Matrix (Fin 2) (Fin 2) ℚ)ᵀ.submatrix sw.symm sw.symm = !![1/2, -1; 1/2, 1] ∧ + Matrix.diagonal ![1, 1/2] * (!![1/2, -1; 1/2, 1] : Matrix (Fin 2) (Fin 2) ℚ) * Matrix.diagonal ![2, 1] = + !![1, -1; 1/2, 1/2] := by + constructor + · ext i j; fin_cases i <;> fin_cases j <;> simp [sw, Equiv.swap_apply_def] + · ext i j; fin_cases i <;> fin_cases j <;> simp [Matrix.mul_apply, Fin.sum_univ_two] <;> norm_num + +end Blocks + +/-! ### Part 5: caveat, COPY does not dualise to an ADD at matrix level -/ +section Caveat +/-- COPY 0 <- 1 on two registers has matrix [[0,1],[0,1]]; its transpose is [[0,0],[1,1]], which is not an ADD matrix +1 + q e_ab (a != b: every ADD matrix has diagonal 1). DU1's "COPY becomes ADD" holds only for a clean target. -/ +theorem copy_not_add (a b : Fin 2) (hab : a ≠ b) (q : ℚ) : + (!![0, 1; 0, 1] : Matrix (Fin 2) (Fin 2) ℚ)ᵀ ≠ 1 + Matrix.single a b q := by + intro h + have := congrFun (congrFun h 0) 0 + simp [Matrix.single_apply] at this + by_cases h0 : a = 0 ∧ b = 0 + · exact hab (h0.1.trans h0.2.symm) + · simp [h0] at this + +end Caveat + +end WordDuality + +#print axioms WordDuality.dual_run +#print axioms WordDuality.Mrec_dual +#print axioms WordDuality.dualH_invoice +#print axioms WordDuality.word_invoice +#print axioms WordDuality.selfdual_boundary +#print axioms WordDuality.nonhosted_block +#print axioms WordDuality.copy_not_add diff --git a/research/p104-tiered-ceiling/lean/Nov15/WordDuality.md b/research/p104-tiered-ceiling/lean/Nov15/WordDuality.md new file mode 100644 index 0000000000..4459df8d1c --- /dev/null +++ b/research/p104-tiered-ceiling/lean/Nov15/WordDuality.md @@ -0,0 +1,12 @@ +# WordDuality : DU1's D = sigma . perp . reversal . transpose in Lean + +`Nov15/WordDuality.lean`, kernel only: no `sorry`, no `native_decide`; axioms within `[propext, Classical.choice, Quot.sound]`. Builds in 11 s / 2.9 GB. Reuses `FibreK` (Table, Helper, nativeInv, K_word, FK) and `CallerCost`. +Model (problem data as hypotheses): `Charts C N` = charts with an involution `perp`, `dim (perp c) = N - dim c`, hubs z, V, `perp z = V` (P104: N = 9). Registers `Reg`, a word = initial chart of each register + a list of events (MOVE a→b, ADD, SCALE, COPY, INIT, CLEAR). Legal = co-presence at the event chart, no MOVE leaves V, none enters z (T1), and a move relation R (public ascent / owned descent) with R a b → R (perp b) (perp a). +1. `dual_run`, `dual_legal`: if w is legal then D w (events reversed, MOVE a→b ↦ perp b→perp a, ADD r += q s @U ↦ ADD s += q r @U^perp, SCALE kept, INIT ↔ CLEAR, COPY ↦ ADD) is legal, starts at perp of w's final charts and ends at perp of w's initial charts (`dual_boundary`; dims: `dual_dim_boundary`). Hub rules swap (z ↔ V), ascent stays ascent (`ascent_dual`) and descent stays descent (`descent_dual`). +2. `Mrec_dual`: for words of MOVE/ADD/SCALE, the product matrix of D l is the σ-relabelled transpose of that of l (K a commutative ring). +3. Invoice: `helperOf_dual`: register σ r of D w is the dual helper (b,e,steps) ↦ (N−e, N−b, reversed swapped steps) of r. `dualH_invoice`: FibreK's Theorem-K invoice Fi(nativeInv E tb H) is unchanged (hypotheses b ≤ e ≤ N, step dims ≤ N), `dualH_root`: same roots of the caller invoice (κ-neutral), `word_invoice` at word level (listed registers climb). Births/ends (b,e) ↦ (N−e,N−b), climb e−b and every MOVE |Δdim| preserved. +4. `selfdual_boundary`: with σ swapping X_p ↔ Y_p, X_p: ⟨p⟩ → V, Y_p: {0} → p^perp, perp ⟨p⟩ = p^perp: D w has exactly the same register boundaries (g = id). `hosted_block`: [[1,0],[1,1]] is invariant under transpose + swap; `nonhosted_block`: with F = [[1,−1],[1/2,1/2]] (reconstructed from DU1's dual [[1/2,−1],[1/2,1]]), D(F) = [[1/2,−1],[1/2,1]] and diag(1,1/2)·D(F)·diag(2,1) = F. + +## Correction to DU1 wording (stated at once) +DU1: "COPY becomes ADD". As matrices this is false: `copy_not_add` (COPY 0←1 has matrix [[0,1],[0,1]], whose transpose [[0,0],[1,1]] is not 1 + q·e_ab for any a ≠ b, ADD matrices have diagonal 1). The dual of a COPY is an ADD only on a clean target (the usual INIT-then-COPY use) and must carry the dual of the target's INIT (a CLEAR). `dualEv` sends COPY ↦ ADD for legality only; matrix semantics (`Mrec_dual`) is restricted to MOVE/ADD/SCALE. +Not formalised: the P104 chart/physical check (DU1 caveat 2), the 271 missing perp frames, and the palindromic construction W = D(A).A. diff --git a/research/p104-tiered-ceiling/lean/lake-manifest.json b/research/p104-tiered-ceiling/lean/lake-manifest.json new file mode 100644 index 0000000000..e4290db056 --- /dev/null +++ b/research/p104-tiered-ceiling/lean/lake-manifest.json @@ -0,0 +1,117 @@ +{ + "version": "1.2.0", + "packagesDir": ".lake/packages", + "packages": [ + { + "url": "https://github.com/leanprover-community/mathlib4.git", + "type": "git", + "subDir": null, + "scope": "", + "rev": "55b7917b472489c7c56a0fa6393af05cfd536599", + "name": "mathlib", + "manifestFile": "lake-manifest.json", + "inputRev": "55b7917b472489c7c56a0fa6393af05cfd536599", + "inherited": false, + "configFile": "lakefile.lean" + }, + { + "url": "https://github.com/leanprover-community/plausible", + "type": "git", + "subDir": null, + "scope": "leanprover-community", + "rev": "b1c4a69a7e247ab7df20460212001673d74f08c0", + "name": "plausible", + "manifestFile": "lake-manifest.json", + "inputRev": "main", + "inherited": true, + "configFile": "lakefile.toml" + }, + { + "url": "https://github.com/leanprover-community/LeanSearchClient", + "type": "git", + "subDir": null, + "scope": "leanprover-community", + "rev": "0498c7c070c143a3bf7379f4d99a2c63bb9d9715", + "name": "LeanSearchClient", + "manifestFile": "lake-manifest.json", + "inputRev": "main", + "inherited": true, + "configFile": "lakefile.toml" + }, + { + "url": "https://github.com/leanprover-community/import-graph", + "type": "git", + "subDir": null, + "scope": "leanprover-community", + "rev": "18a90119a5d316358fde6c86e0ca24e59212e32c", + "name": "importGraph", + "manifestFile": "lake-manifest.json", + "inputRev": "main", + "inherited": true, + "configFile": "lakefile.toml" + }, + { + "url": "https://github.com/leanprover-community/ProofWidgets4", + "type": "git", + "subDir": null, + "scope": "leanprover-community", + "rev": "b1436dc749e722c9920036b52cdc43b3451d0b69", + "name": "proofwidgets", + "manifestFile": "lake-manifest.json", + "inputRev": "main", + "inherited": true, + "configFile": "lakefile.lean" + }, + { + "url": "https://github.com/leanprover-community/aesop", + "type": "git", + "subDir": null, + "scope": "leanprover-community", + "rev": "57d3325be72a842920813bcb40f96a6f7393c185", + "name": "aesop", + "manifestFile": "lake-manifest.json", + "inputRev": "master", + "inherited": true, + "configFile": "lakefile.toml" + }, + { + "url": "https://github.com/leanprover-community/quote4", + "type": "git", + "subDir": null, + "scope": "leanprover-community", + "rev": "ee41917ae11d38479fb8fb24745f7ca4bf0a784d", + "name": "Qq", + "manifestFile": "lake-manifest.json", + "inputRev": "master", + "inherited": true, + "configFile": "lakefile.toml" + }, + { + "url": "https://github.com/leanprover-community/batteries", + "type": "git", + "subDir": null, + "scope": "leanprover-community", + "rev": "2c810760f0a0c4536b397dbe30ca9b2f2f467366", + "name": "batteries", + "manifestFile": "lake-manifest.json", + "inputRev": "main", + "inherited": true, + "configFile": "lakefile.toml" + }, + { + "url": "https://github.com/leanprover/lean4-cli", + "type": "git", + "subDir": null, + "scope": "leanprover", + "rev": "da07ca808b6718cb2aed14dba154e5a08b8f8ecf", + "name": "Cli", + "manifestFile": "lake-manifest.json", + "inputRev": "v4.33.0-rc1", + "inherited": true, + "configFile": "lakefile.toml" + } + ], + "name": "Nov16Core", + "lakeDir": ".lake", + "fixedToolchain": false +} diff --git a/research/p104-tiered-ceiling/lean/lakefile.toml b/research/p104-tiered-ceiling/lean/lakefile.toml new file mode 100644 index 0000000000..a5692331ac --- /dev/null +++ b/research/p104-tiered-ceiling/lean/lakefile.toml @@ -0,0 +1,12 @@ +name = "NativeCeiling" +defaultTargets = ["Nov15"] + +[[require]] +name = "mathlib" +git = "https://github.com/leanprover-community/mathlib4.git" +# pinned to the exact commit used for every check in this package (same as lake-manifest.json) +rev = "55b7917b472489c7c56a0fa6393af05cfd536599" + +[[lean_lib]] +name = "Nov15" +globs = ["Nov15.+"] diff --git a/research/p104-tiered-ceiling/lean/lean-toolchain b/research/p104-tiered-ceiling/lean/lean-toolchain new file mode 100644 index 0000000000..fd85b262bf --- /dev/null +++ b/research/p104-tiered-ceiling/lean/lean-toolchain @@ -0,0 +1 @@ +leanprover/lean4:v4.33.0-rc1