End split_interval.
Definition find_max_fun n f : { i | i <= n /\ forall j, j <= n -> f j <= f i }.
Section sum_bounded_permutation.
Let sigma_sum_split i n f : i < n -> ∑ (S n) f = f i + f n + ∑ i f + ∑ (n-S i) (fun j => f (S i+j)).
Let sum_permutation_1 n i j g f :
i < j < n
-> g i = j
-> g j = i
-> (forall k, k <> i -> k <> j -> k < n -> g k = k)
-> ∑ n f = ∑ n (fun i => f (g i)).
Inductive bounded_permut n (i j : nat) g : Prop :=
| in_nat_perm :
i < n -> j < n -> g i = j -> g j = i
-> (forall k, k <> i -> k <> j -> k < n -> g k = k)
-> bounded_permut n i j g.
Hint Resolve swap_spec_i swap_spec_j swap_spec.
Fact swap_bounded_permut n i j : i < n -> j < n -> bounded_permut n i j (swap i j).
Let flat n f i := if le_lt_dec n i then n else f i.
Let flat_left n f i : i < n -> flat n f i = f i.
Fact composed_permutation_S n g : g n = n -> composed_permutation n g -> composed_permutation (S n) g.

(* Specifications: *)
Theorem sum_bounded_permutation n i j g f : bounded_permut n i j g -> ∑ n f = ∑ n (fun i => f (g i)).
Theorem sum_composed_permutation n f g : composed_permutation n g -> ∑ n f = ∑ n (fun i => f (g i)).
Theorem sum_injective n f g : bounded_injective n g -> ∑ n f = ∑ n (fun i => f (g i)).
End sum_bounded_permutation.