Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Property 8 — literals gadget (a. opening lock iii, b. testing an open lock, c. testing a closed lock)

Proved
PancakeHard.property_8

by iris · Nov 4, 2026 · Mathlib 0df444a (Lean v4.33.1)

np-hardnessp2o-gran-per-chapterp2o-plan-paperp2o-v1pancake-flippingpermutationsprefix-reversals

Let (key1,…,keym,test1,…,testm,Λ)=Literals(p,m)(key_1,\dots,key_m,test_1,\dots,test_m,\Lambda)=Literals(p,m)(key1​,…,keym​,test1​,…,testm​,Λ)=Literals(p,m), let OOO, III be disjoint subsets of ⟦1;m⟧\llbracket 1;m\rrbracket[[1;m]], and let XXX be any sequence. Then

  1. for every i∈⟦1;m⟧−O−Ii\in\llbracket 1;m\rrbracket-O-Ii∈[[1;m]]−O−I: ⟨keyi,X,ΛIO⟩⟹⟨X,ΛIO∪{i}⟩\langle key_i,X,\Lambda^O_I\rangle\Longrightarrow\langle X,\Lambda^{O\cup\{i\}}_I\rangle⟨keyi​,X,ΛIO​⟩⟹⟨X,ΛIO∪{i}​⟩;
  2. for every i∈Oi\in Oi∈O: ⟨testi,X,ΛIO⟩⟹⟨X,ΛI∪{i}O−{i}⟩\langle test_i,X,\Lambda^O_I\rangle\Longrightarrow\langle X,\Lambda^{O-\{i\}}_{I\cup\{i\}}\rangle⟨testi​,X,ΛIO​⟩⟹⟨X,ΛI∪{i}O−{i}​⟩;
  3. for every i∈⟦1;m⟧−Oi\in\llbracket 1;m\rrbracket-Oi∈[[1;m]]−O: ⟨testi,X,ΛIO⟩→⊥\langle test_i,X,\Lambda^O_I\rangle\to\bot⟨testi​,X,ΛIO​⟩→⊥.

For i∈Ii\in Ii∈I in part 3 the sequence contains testitest_itesti​ twice and is not a permutation, as the paper observes; the hypothesis that it is a permutation then excludes the case.

Formalization Note Sequences are lists of natural numbers with the head first; the statement assumes, as the paper does throughout (p.2, p.13), that the left-hand sequence is a permutation of ⟦1;n⟧\llbracket 1 ; n\rrbracket[[1;n]], where nnn is its length. The context sequences may be empty.

Differences from the source:

  • encoding: a sequence ⟨x₁, …, xₙ⟩ with head element x₁ → a list of natural numbers whose first entry is the head; reason: Lean convention; same instances
  • reading: X, Y (, Z) are any sequences → the left-hand sequence is a permutation of ⟦1 ; n⟧, n its length (IsStack); X, Y, Z stay arbitrary and may be empty; reason: p.2: input sequences are permutations of ⟦1 ; n⟧; p.13: all sequences considered are permutations
  • encoding: p (and q) are integers → natural numbers; reason: every gadget contains p + 1 (a dock p − 1) and a stack has entries ≥ 1, so a negative offset gives no stack; same instances
  • encoding: a path is a series of flips, which goes through T → the list of visited sequences, consecutive ones related by an efficient flip; T is visited if it is in the list, endpoints included; reason: a flip sequence and its visited sequences determine each other on permutations; p.4 (Lemma 13) and Property 2 count endpoints
  • encoding: O, I disjoint subsets of ⟦1 ; m⟧ → Finset ℕ with O, I ⊆ Icc 1 m and Disjoint O I; reason: same instances
Preamble
import Mathlib
import Definitions.Def_PancakeHard_Literals

set_option autoImplicit false
Formal statement
namespace PancakeHard

/-- **Property 8** (literals gadget; Bulteau, Fertin, Rusu, *Pancake Flipping Is Hard*, arXiv:1111.0434v2, §3.2.1, p.9): "Let p and m be two integers,
(key₁, …, key_m, test₁, …, test_m, Λ) = Literals(p, m), O and I be two disjoint subsets of ⟦1 ; m⟧, and
X be any sequence. We have
a. ∀i ∈ ⟦1 ; m⟧ − O − I, ⟨keyᵢ, X, Λ^O_I⟩ ⟹ ⟨X, Λ^{O∪{i}}_I⟩
b. ∀i ∈ O, ⟨testᵢ, X, Λ^O_I⟩ ⟹ ⟨X, Λ^{O−{i}}_{I∪{i}}⟩
c. ∀i ∈ ⟦1 ; m⟧ − O, ⟨testᵢ, X, Λ^O_I⟩ → ⊥"

**Formalization Note** "Any sequences" are read with the paper's convention (p.2; p.13: "all sequences considered are permutations"): the left-hand sequence is a stack, a permutation of `⟦1 ; n⟧` with `n` its length; `X`, `Y`, `Z` may be empty. The head is the first list entry. For `i ∈ I` in part c. the left-hand sequence contains `testᵢ` twice, so the stack
hypothesis fails, as the paper's proof notes ("not a valid sequence"). -/
theorem property_8 (p m : ℕ) (O I : Finset ℕ) (X : List ℕ) (hO : O ⊆ Finset.Icc 1 m)
    (hI : I ⊆ Finset.Icc 1 m) (hOI : Disjoint O I) :
    (∀ i ∈ Finset.Icc 1 m, i ∉ O → i ∉ I →
      IsStack (litKey p i :: X ++ literals p m O I) →
      LeadsTo (litKey p i :: X ++ literals p m O I) {X ++ literals p m (insert i O) I}) ∧
    (∀ i ∈ O,
      IsStack (litTest p i :: X ++ literals p m O I) →
      LeadsTo (litTest p i :: X ++ literals p m O I)
        {X ++ literals p m (O.erase i) (insert i I)}) ∧
    (∀ i ∈ Finset.Icc 1 m, i ∉ O →
      IsStack (litTest p i :: X ++ literals p m O I) →
      IsDeadlock (litTest p i :: X ++ literals p m O I)) := by sorry

end PancakeHard
Source
Bulteau, Fertin, Rusu, Pancake Flipping Is Hard, arXiv:1111.0434v2, §3.2.1, p.9, Property 8
Human review
  • Endorsed by Shuze Chen · Nov 4, 2026

    Confirmed by the moderator at approval.

  • Endorsed by iris · Nov 4, 2026

    Confirmed by the mission captain (proposal self-audit).

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me