PA004U

finite_swap_last_surjective_back

Stable checked-use theorem · independently closed

Surjectivity of a swapped successor prefix transports back to the original code.

Current library: Alpha v34, 4,223 checked-use theorems; Stable remains 432. Historical first admissions, original proof editions, and non-admitted aliases are preserved. Exact original first-admission records.

Exact expanded PA statement

forall b c z d n sn i x y. sn = S n -> (exists h. h + S i = n) -> (((exists ff_h_swap_surj_old_i. ff_h_swap_surj_old_i + S (x) = S ((S (i)) * c)) /\ exists ff_q_swap_surj_old_i. b = ff_q_swap_surj_old_i * S ((S (i)) * c) + (x))) -> (((exists ff_h_swap_surj_old_n. ff_h_swap_surj_old_n + S (y) = S ((S (n)) * c)) /\ exists ff_q_swap_surj_old_n. b = ff_q_swap_surj_old_n * S ((S (n)) * c) + (y))) -> (((exists ff_h_swap_surj_new_i. ff_h_swap_surj_new_i + S (y) = S ((S (i)) * d)) /\ exists ff_q_swap_surj_new_i. z = ff_q_swap_surj_new_i * S ((S (i)) * d) + (y))) -> (((exists ff_h_swap_surj_new_n. ff_h_swap_surj_new_n + S (x) = S ((S (n)) * d)) /\ exists ff_q_swap_surj_new_n. z = ff_q_swap_surj_new_n * S ((S (n)) * d) + (x))) -> (forall j a. (exists h. h + S j = S n) -> ~(j = i) -> ~(j = n) -> (((exists ff_h_swap_surj_old_j. ff_h_swap_surj_old_j + S (a) = S ((S (j)) * c)) /\ exists ff_q_swap_surj_old_j. b = ff_q_swap_surj_old_j * S ((S (j)) * c) + (a))) -> (((exists ff_h_swap_surj_new_j. ff_h_swap_surj_new_j + S (a) = S ((S (j)) * d)) /\ exists ff_q_swap_surj_new_j. z = ff_q_swap_surj_new_j * S ((S (j)) * d) + (a)))) -> (forall fp_value_swap_surj_new. (exists fp_gap_swap_surj_new_value. fp_gap_swap_surj_new_value + S fp_value_swap_surj_new = sn) -> exists fp_i_swap_surj_new. ((exists fp_gap_swap_surj_new_index. fp_gap_swap_surj_new_index + S fp_i_swap_surj_new = sn) /\ (((exists ff_h_swap_surj_new_entry. ff_h_swap_surj_new_entry + S (fp_value_swap_surj_new) = S ((S (fp_i_swap_surj_new)) * d)) /\ exists ff_q_swap_surj_new_entry. z = ff_q_swap_surj_new_entry * S ((S (fp_i_swap_surj_new)) * d) + (fp_value_swap_surj_new))))) -> (forall fp_value_swap_surj_old. (exists fp_gap_swap_surj_old_value. fp_gap_swap_surj_old_value + S fp_value_swap_surj_old = sn) -> exists fp_i_swap_surj_old. ((exists fp_gap_swap_surj_old_index. fp_gap_swap_surj_old_index + S fp_i_swap_surj_old = sn) /\ (((exists ff_h_swap_surj_old_entry. ff_h_swap_surj_old_entry + S (fp_value_swap_surj_old) = S ((S (fp_i_swap_surj_old)) * c)) /\ exists ff_q_swap_surj_old_entry. b = ff_q_swap_surj_old_entry * S ((S (fp_i_swap_surj_old)) * c) + (fp_value_swap_surj_old)))))

Structural proof guide

Generated structural guide

Surjectivity of a swapped successor prefix transports back to the original code.

Use the direct prerequisites beta_prefix_swap_last_reflect, le_succ, le_refl as previously established PA formulas.

The proof proceeds by case analysis (8), intermediate claims (6), equality transport (8).

Referenced ingredients

Proof neighborhood

Direct dependencies

Direct dependents

Formal native tactic body

Dependencies are introduced as named hypotheses before line 1. Linked names are exact direct references. This Stable checked-use theorem is independently kernel-checked when replayed.

Read the argument

Proof checkpoints

80 script commands · 27 reading checkpoints · 6 local claims

This is a reading aid, not a new proof or a proof-tree certificate. Checkpoint groups are consecutive commands, not inferred branch boundaries. Every step links to the preserved script.

Named ingredients (3)

Long local formulas use this family’s existing definitions. Each new abbreviation was expanded back to the identical native formula, including its free-variable context. The original edition is preserved below.

01Fix variables and assumptionsL1–10

Work with arbitrary variables or the premises of the current implication.

  1. L1
    intro b
  2. L2
    intro c
  3. L3
    intro z
  4. L4
    intro d
  5. L5
    intro n
  6. L6
    intro sn
  7. L7
    intro i
  8. L8
    intro x
  9. L9
    intro y
  10. L10
    intro hsn
02Fix variables and assumptionsL11–17

Work with arbitrary variables or the premises of the current implication.

  1. L11
    intro hi
  2. L12
    intro hold_i
  3. L13
    intro hold_n
  4. L14
    intro hnew_i
  5. L15
    intro hnew_n
  6. L16
    intro hpreserve
  7. L17
    intro hsurjective
03Calculate and transport equalitiesL18–19

Carry out the recorded arithmetic or equality steps; inspect the exact commands for their direction and premises.

  1. L18
    rewrite hsn at hsurjective
  2. L19
    rewrite hsn at hsurjective
04Establish hisnL20–24

Establish this local claim before using it. It is not an additional assumption. The following proof commands apply le succ.

  1. L20
    have hisn : exists h. h + S i = S n
  2. L21
    specialize le_succ (S i)
  3. L22
    specialize le_succ n
  4. L23
    apply le_succ
  5. L24
    exact hi
05Establish hnsnL25–27

Establish this local claim before using it. It is not an additional assumption.

  1. L25
    have hnsn : exists h. h + S n = S n
  2. L26
    specialize le_refl (S n)
  3. L27
    exact le_refl
06Establish hreflectL28–37

Establish this local claim before using it. It is not an additional assumption.

  1. L28
    have hreflect : ∀ b. ∀ c. ∀ z. ∀ d. ∀ n. ∀ i. ∀ x. ∀ y. BetaAt(z,d,i,y) → BetaAt(z,d,n,x) → (∀ m. ∀ k. Lt(m,S n) → ¬m = i → ¬m = n → BetaAt(b,c,m,k) → BetaAt(z,d,m,k)) → ∀ m. ∀ k. Lt(m,S n) → BetaAt(z,d,m,k) → m = i ∧ k = y ∨ (m = n ∧ k = x ∨ ¬m = i ∧ (¬m = n ∧ BetaAt(b,c,m,k)))Definitions: LtBetaAt
  2. L29
    exact beta_prefix_swap_last_reflect
  3. L30
    specialize hreflect b
  4. L31
    specialize hreflect c
  5. L32
    specialize hreflect z
  6. L33
    specialize hreflect d
  7. L34
    specialize hreflect n
  8. L35
    specialize hreflect i
  9. L36
    specialize hreflect x
  10. L37
    specialize hreflect y
07Establish hreflect_entriesL38–47

Establish this local claim before using it. It is not an additional assumption. The following proof commands apply hreflect.

  1. L38
    have hreflect_entries : forall j a. (exists h. h + S j = S n) -> ((exists h. h + S a = S ((S j) * d)) /\ exists q. z = q * S ((S j) * d) + a) -> ((j = i /\ a = y) \/ ((j = n /\ a = x) \/ (~(j = i) /\ (~(j = n) /\ ((exists h. h + S a = S ((S j) * c)) /\ exists q. b = q * S ((S j) * c) + a)))))
  2. L39
    apply hreflect
  3. L40
    exact hnew_i
  4. L41
    exact hnew_n
  5. L42
    exact hpreserve
  6. L43
    rewrite hsn
  7. L44
    rewrite hsn
  8. L45
    intro a
  9. L46
    intro ha
  10. L47
    specialize hsurjective a
08Establish hoccursL48–50

Establish this local claim before using it. It is not an additional assumption. The following proof commands apply hsurjective.

  1. L48
    have hoccurs : exists j. ((exists h. h + S j = S n) /\ ((exists h. h + S a = S ((S j) * d)) /\ exists q. z = q * S ((S j) * d) + a))
  2. L49
    apply hsurjective
  3. L50
    exact ha
09Separate the logical casesL51–52

Follow the explicit conjunction, disjunction, witness, or contradiction step recorded below.

  1. L51
    cases hoccurs
  2. L52
    cases hoccurs_witness
10Use earlier factsL53–54

Instantiate or apply named facts and discharge the corresponding proof obligations.

  1. L53
    specialize hreflect_entries x1
  2. L54
    specialize hreflect_entries a
11Establish hsourceL55–58

Establish this local claim before using it. It is not an additional assumption. The following proof commands apply hreflect entries.

  1. L55
    have hsource : ((x1 = i /\ a = y) \/ ((x1 = n /\ a = x) \/ (~(x1 = i) /\ (~(x1 = n) /\ ((exists h. h + S a = S ((S x1) * c)) /\ exists q. b = q * S ((S x1) * c) + a)))))
  2. L56
    apply hreflect_entries
  3. L57
    exact hoccurs_witness_left
  4. L58
    exact hoccurs_witness_right
12Separate the logical casesL59–60

Follow the explicit conjunction, disjunction, witness, or contradiction step recorded below.

  1. L59
    cases hsource
  2. L60
    cases hsource_left
13Construct an explicit witnessL61–61

Supply the displayed value, then prove that it has the required property.

  1. L61
    exists n
14Separate the logical casesL62–62

Follow the explicit conjunction, disjunction, witness, or contradiction step recorded below.

  1. L62
    split
15Use earlier factsL63–63

Instantiate or apply named facts and discharge the corresponding proof obligations.

  1. L63
    exact hnsn
16Calculate and transport equalitiesL64–65

Carry out the recorded arithmetic or equality steps; inspect the exact commands for their direction and premises.

  1. L64
    rewrite hsource_left_right
  2. L65
    rewrite hsource_left_right
17Use earlier factsL66–66

Instantiate or apply named facts and discharge the corresponding proof obligations.

  1. L66
    exact hold_n
18Separate the logical casesL67–68

Follow the explicit conjunction, disjunction, witness, or contradiction step recorded below.

  1. L67
    cases hsource_right
  2. L68
    cases hsource_right_left
19Construct an explicit witnessL69–69

Supply the displayed value, then prove that it has the required property.

  1. L69
    exists i
20Separate the logical casesL70–70

Follow the explicit conjunction, disjunction, witness, or contradiction step recorded below.

  1. L70
    split
21Use earlier factsL71–71

Instantiate or apply named facts and discharge the corresponding proof obligations.

  1. L71
    exact hisn
22Calculate and transport equalitiesL72–73

Carry out the recorded arithmetic or equality steps; inspect the exact commands for their direction and premises.

  1. L72
    rewrite hsource_right_left_right
  2. L73
    rewrite hsource_right_left_right
23Use earlier factsL74–74

Instantiate or apply named facts and discharge the corresponding proof obligations.

  1. L74
    exact hold_i
24Separate the logical casesL75–76

Follow the explicit conjunction, disjunction, witness, or contradiction step recorded below.

  1. L75
    cases hsource_right_right
  2. L76
    cases hsource_right_right_right
25Construct an explicit witnessL77–77

Supply the displayed value, then prove that it has the required property.

  1. L77
    exists x1
26Separate the logical casesL78–78

Follow the explicit conjunction, disjunction, witness, or contradiction step recorded below.

  1. L78
    split
27Use earlier factsL79–80

Instantiate or apply named facts and discharge the corresponding proof obligations.

  1. L79
    exact hoccurs_witness_left
  2. L80
    exact hsource_right_right_right_right

Library-wide reading audit

Original exact command ledger · 80 lines
  1. 0001intro b
  2. 0002intro c
  3. 0003intro z
  4. 0004intro d
  5. 0005intro n
  6. 0006intro sn
  7. 0007intro i
  8. 0008intro x
  9. 0009intro y
  10. 0010intro hsn
  11. 0011intro hi
  12. 0012intro hold_i
  13. 0013intro hold_n
  14. 0014intro hnew_i
  15. 0015intro hnew_n
  16. 0016intro hpreserve
  17. 0017intro hsurjective
  18. 0018rewrite hsn at hsurjective
  19. 0019rewrite hsn at hsurjective
  20. 0020have hisn : exists h. h + S i = S n
  21. 0021specialize le_succ (S i)
  22. 0022specialize le_succ n
  23. 0023apply le_succ
  24. 0024exact hi
  25. 0025have hnsn : exists h. h + S n = S n
  26. 0026specialize le_refl (S n)
  27. 0027exact le_refl
  28. 0028have hreflect : forall b c z d n i x y. (((exists ff_h_reflect_new_i. ff_h_reflect_new_i + S (y) = S ((S (i)) * d)) /\ exists ff_q_reflect_new_i. z = ff_q_reflect_new_i * S ((S (i)) * d) + (y))) -> (((exists ff_h_reflect_new_n. ff_h_reflect_new_n + S (x) = S ((S (n)) * d)) /\ exists ff_q_reflect_new_n. z = ff_q_reflect_new_n * S ((S (n)) * d) + (x))) -> (forall k v. (exists h. h + S k = S n) -> ~(k = i) -> ~(k = n) -> (((exists ff_h_reflect_old_k. ff_h_reflect_old_k + S (v) = S ((S (k)) * c)) /\ exists ff_q_reflect_old_k. b = ff_q_reflect_old_k * S ((S (k)) * c) + (v))) -> (((exists ff_h_reflect_new_k. ff_h_reflect_new_k + S (v) = S ((S (k)) * d)) /\ exists ff_q_reflect_new_k. z = ff_q_reflect_new_k * S ((S (k)) * d) + (v)))) -> forall j a. (exists h. h + S j = S n) -> (((exists ff_h_reflect_new_j. ff_h_reflect_new_j + S (a) = S ((S (j)) * d)) /\ exists ff_q_reflect_new_j. z = ff_q_reflect_new_j * S ((S (j)) * d) + (a))) -> ((j = i /\ a = y) \/ ((j = n /\ a = x) \/ (~(j = i) /\ (~(j = n) /\ (((exists ff_h_reflect_old_j. ff_h_reflect_old_j + S (a) = S ((S (j)) * c)) /\ exists ff_q_reflect_old_j. b = ff_q_reflect_old_j * S ((S (j)) * c) + (a)))))))
  29. 0029exact beta_prefix_swap_last_reflect
  30. 0030specialize hreflect b
  31. 0031specialize hreflect c
  32. 0032specialize hreflect z
  33. 0033specialize hreflect d
  34. 0034specialize hreflect n
  35. 0035specialize hreflect i
  36. 0036specialize hreflect x
  37. 0037specialize hreflect y
  38. 0038have hreflect_entries : forall j a. (exists h. h + S j = S n) -> ((exists h. h + S a = S ((S j) * d)) /\ exists q. z = q * S ((S j) * d) + a) -> ((j = i /\ a = y) \/ ((j = n /\ a = x) \/ (~(j = i) /\ (~(j = n) /\ ((exists h. h + S a = S ((S j) * c)) /\ exists q. b = q * S ((S j) * c) + a)))))
  39. 0039apply hreflect
  40. 0040exact hnew_i
  41. 0041exact hnew_n
  42. 0042exact hpreserve
  43. 0043rewrite hsn
  44. 0044rewrite hsn
  45. 0045intro a
  46. 0046intro ha
  47. 0047specialize hsurjective a
  48. 0048have hoccurs : exists j. ((exists h. h + S j = S n) /\ ((exists h. h + S a = S ((S j) * d)) /\ exists q. z = q * S ((S j) * d) + a))
  49. 0049apply hsurjective
  50. 0050exact ha
  51. 0051cases hoccurs
  52. 0052cases hoccurs_witness
  53. 0053specialize hreflect_entries x1
  54. 0054specialize hreflect_entries a
  55. 0055have hsource : ((x1 = i /\ a = y) \/ ((x1 = n /\ a = x) \/ (~(x1 = i) /\ (~(x1 = n) /\ ((exists h. h + S a = S ((S x1) * c)) /\ exists q. b = q * S ((S x1) * c) + a)))))
  56. 0056apply hreflect_entries
  57. 0057exact hoccurs_witness_left
  58. 0058exact hoccurs_witness_right
  59. 0059cases hsource
  60. 0060cases hsource_left
  61. 0061exists n
  62. 0062split
  63. 0063exact hnsn
  64. 0064rewrite hsource_left_right
  65. 0065rewrite hsource_left_right
  66. 0066exact hold_n
  67. 0067cases hsource_right
  68. 0068cases hsource_right_left
  69. 0069exists i
  70. 0070split
  71. 0071exact hisn
  72. 0072rewrite hsource_right_left_right
  73. 0073rewrite hsource_right_left_right
  74. 0074exact hold_i
  75. 0075cases hsource_right_right
  76. 0076cases hsource_right_right_right
  77. 0077exists x1
  78. 0078split
  79. 0079exact hoccurs_witness_left
  80. 0080exact hsource_right_right_right_right