AFTD Auto-Formalizing Theoretical Domains

op874_almost_complete_relation_contains_permutation

theoremverified

A two-state relation that excludes at most one ordered pair contains a bijection.

Statement

theorem op874_almost_complete_relation_contains_permutation
    (R : Bool → Bool → Prop)
    (hR : ∀ a b c d : Bool, (a,b) ≠ (c,d) → R a b ∨ R c d) :
    ∃ f : Bool → Bool, f false ≠ f true ∧ ∀ a, R a (f a)
Source
Finite local-phase reduction for OP-874, https://arxiv.org/abs/2610.41950, Section 2.
Verified
27 Nov 2026
Axioms
Classical.choiceQuot.soundpropext

The proof, explained

The relation R on the two-element boolean domain excludes at most one ordered pair by hypothesis. There are only two permutations of Bool: the identity function and the boolean negation function. If both diagonal pairs (false, false) and (true, true) belong to R, the identity function is a bijection contained in R. Otherwise, at least one diagonal pair is missing, which forces both off-diagonal pairs to belong to R, meaning the negation function provides the required bijection.

  1. If both diagonal pairs (false, false) and (true, true) belong to R, the identity function is the required bijection.

    Using classical logic, we split into cases based on whether (false, false) and (true, true) belong to R. When both diagonal pairs are in R, the identity map f = id satisfies the requirements: id(false) ≠ id(true) holds by definition, and R(a, id(a)) holds for every boolean a since R(false, false) and R(true, true) both hold.

    lines 5–8

    uses id

      classical
      by_cases h00 : R false false
      · by_cases h11 : R true true
        · exact ⟨id, by decide, by intro a; cases a <;> simp_all⟩
  2. If (false, false) belongs to R but (true, true) does not, the boolean negation function is the required bijection.

    Since (true, true) does not belong to R, the hypothesis hR guarantees that every other pair must belong to R. Specifically, testing (false, true) against (true, true) and (true, false) against (true, true) shows that both off-diagonal pairs R(false, true) and R(true, false) must hold. Consequently, the swap function f = Bool.not satisfies f(false) ≠ f(true) as well as R(a, f(a)) for all a.

    lines 9–12

    uses Bool.not

        · have h01 := hR false true true true (by decide)
          have h10 := hR true false true true (by decide)
          refine ⟨Bool.not, by decide, ?_⟩
          intro a; cases a <;> simp_all
  3. If (false, false) does not belong to R, the boolean negation function is the required bijection.

    Similarly, when (false, false) is missing from R, hypothesis hR applied to (false, true) versus (false, false) and (true, false) versus (false, false) forces both off-diagonal pairs R(false, true) and R(true, false) to belong to R. Hence, the negation function f = Bool.not again yields a permutation entirely contained in R, completing the proof.

    lines 13–16

    uses Bool.not

      · have h01 := hR false true false false (by decide)
        have h10 := hR true false false false (by decide)
        refine ⟨Bool.not, by decide, ?_⟩
        intro a; cases a <;> simp_all
id
The identity function, sending each element to itself.
Bool.not
The boolean negation function, mapping true to false and false to true.

Written by a model (gemini-3.8-flash) from the Lean proof and the goal states Lean reported at each step. Lean verified the proof; this explanation is a reading aid and is not itself machine-checked.

Lean source view module on GitHub

theorem op874_almost_complete_relation_contains_permutation    (R : Bool → Bool → Prop)    (hR : ∀ a b c d : Bool, (a,b) ≠ (c,d) → R a b ∨ R c d) :    ∃ f : Bool → Bool, f false ≠ f true ∧ ∀ a, R a (f a) := by  classical  by_cases h00 : R false false  · by_cases h11 : R true true    · exact ⟨id, by decide, by intro a; cases a <;> simp_all⟩    · have h01 := hR false true true true (by decide)      have h10 := hR true false true true (by decide)      refine ⟨Bool.not, by decide, ?_⟩      intro a; cases a <;> simp_all  · have h01 := hR false true false false (by decide)    have h10 := hR true false false false (by decide)    refine ⟨Bool.not, by decide, ?_⟩    intro a; cases a <;> simp_all
See it in the graphDiscuss this resultChallenge it