1-- Involutions and restriction to unions of their orbits (ZF).2-- Part of Cumulus, the Grace17 mathematics library.3-- Copyright (c) 2026 Grant Passmore.4-- Released under the Apache License 2.0. See LICENSE in the repository root.5-- Authors: Grant Passmore67module Grace.Cumulus.Set.Involution8import Function910predicate InvolutionOn (t D : Set) := FunctionBetween(t, D, D) ∧ (∀ x ∈ D, t(t(x)) = x)1112theorem InvolutionOn.function (t D : Set)13requires involution : InvolutionOn(t, D)14shows t : D → D15proof16simp [InvolutionOn]1718theorem InvolutionOn.apply (t D x : Set)19requires involution : InvolutionOn(t, D)20requires member : x ∈ D21shows t(t(x)) = x22proof23ext y24simp [InvolutionOn]2526theorem InvolutionOn.bijective (t D : Set)27requires involution : InvolutionOn(t, D)28shows BijectiveBetween(t, D, D)29proof30have function := InvolutionOn.function with involution31constructor32 . unfold InjectiveBetween33refine⟨function, ?_⟩34intros x hx y hy z hz first second35have tx := FunctionBetween.apply_value with function, hx, first36have ty := FunctionBetween.apply_value with function, hy, second37have inverseX := InvolutionOn.apply with involution, hx38have inverseY := InvolutionOn.apply with involution, hy39cc40 . unfold SurjectiveBetween41refine⟨function, ?_⟩42intros y hy43have image := FunctionBetween.apply_closed with function, hy44have inverse := InvolutionOn.apply with involution, hy45have graph := FunctionBetween.relates_apply with function, image46refine⟨t(y), image, ?_⟩47 rwa inverse at graph4849theorem InvolutionOn.remove_pair (t D V a : Set)50requires involution : InvolutionOn(t, D)51requires subset : V ⊆ D52requires closed : ∀ x ∈ V, t(x) ∈ V53requires member : a ∈ V54shows∀ x ∈ (V ∖ {a}) ∖ {t(a)}, t(x) ∈ (V ∖ {a}) ∖ {t(a)}55proof56have aIn := subset with a, member57have inverseA := InvolutionOn.apply with involution, aIn58intros x hx59have outer := difference.membership.forward with hx60have inner := difference.membership.forward with outer.left61have xIn := subset with x, inner.left62have inverseX := InvolutionOn.apply with involution, xIn63have image := closed with x, inner.left64have notA : ¬(t(x) ∈ {a})65intro singleton66have equal := singleton.membership.forward with singleton67have same : x = t(a) bycc68have forbidden : x ∈ {t(a)} bysimp69exact outer.right with forbidden70have notPartner : ¬(t(x) ∈ {t(a)})71intro singleton72have equal := singleton.membership.forward with singleton73have same : x = a bycc74have forbidden : x ∈ {a} bysimp75exact inner.right with forbidden76exact difference.membership.backward with⟨(difference.membership.backward with⟨image, notA⟩), notPartner⟩7778-- Restrict an involution when it exchanges two (possibly overlapping) subsets.79theorem InvolutionOn.restrict_between (t D S T : Set)80requires involution : InvolutionOn(t, D)81requires subsetS : S ⊆ D82requires subsetT : T ⊆ D83requires forward : ∀ x ∈ S, t(x) ∈ T84requires backward : ∀ y ∈ T, t(y) ∈ S85shows BijectiveBetween(restrict(t, S), S, T)86proof87have function := InvolutionOn.function with involution88have restricted := restrict.function at t, D, D, S, T with*89constructor90 . unfold InjectiveBetween91refine⟨restricted, ?_⟩92intros x hx y hy z hz first second93have valueX := FunctionBetween.apply_value with restricted, hx, first94have valueY := FunctionBetween.apply_value with restricted, hy, second95have restrictedX := restrict.apply with hx96have restrictedY := restrict.apply with hy97have xIn := subsetS with x, hx98have yIn := subsetS with y, hy99have inverseX := InvolutionOn.apply with involution, xIn100have inverseY := InvolutionOn.apply with involution, yIn101cc102 . unfold SurjectiveBetween103refine⟨restricted, ?_⟩104intros y hy105have preimage := backward with y, hy106have yIn := subsetT with y, hy107have inverse := InvolutionOn.apply with involution, yIn108have value := restrict.apply at t, D, D, S, T, t(y) with*109have graph := FunctionBetween.relates_apply with restricted, preimage110refine⟨t(y), preimage, ?_⟩111have same : restrict(t, S)(t(y)) = y bycc112 rwa same at graph113