TPPmark 2025
Kenta Inoue
井上健太
解説記事
https://qiita.com/nekonibox/items/bc85ece3ee8e42240fe6
thought
problem
thought
problem
Rubik's cube
similar
thought
problem
Rubik's cube
similar
non-commutative group
thought
problem
Rubik's cube
similar
non-commutative group
commutative group
thought
problem
commutative group
:
fi
eld
{0,1} =
𝔽
2
thought
problem
:
fi
eld
{0,1} =
𝔽
2
linear space
problem
original
-dim hyper-rectangle
d
3-dim cube
generalize
problem
original
-dim hyper-rectangle
d
3-dim cube
generalize
lamp state:
fi
nite
fi
eld
𝔽
p
where is prime
p
{on, o
ff
} ( ∼
𝔽
2)
Why ?
𝔽
p
(∃p : prime, K ∼
𝔽
p)
Field K
∀x ∈ K, ∃n ∈ ℕ, x = n * 1K
↔
cyclic
hyper-cube
-dim hyper-rectangle
d
hyper-cubes
d−1
∏
i=0
ni
(n0, …, nd−1)
hyper-cube
-dim hyper-rectangle
d
hyper-cubes
d−1
∏
i=0
ni
(n0, …, nd−1)
hyper-cubes :=
d−1
∏
i=0
Ini
In := {0, …, n − 1}
state
-dim hyper-rectangle
d
(n0, …, nd−1)
In := {0, …, n − 1}
state:
d−1
∏
i=0
Ini
→
𝔽
p
hyper-cubes :=
d−1
∏
i=0
Ini
state
-dim hyper-rectangle
d
(n0, …, nd−1)
In := {0, …, n − 1}
state:
In × Im ∼ Inm
𝔽
(∏
d−1
i=0
ni)
p
d−1
∏
i=0
Ini
→
𝔽
p
: -dim vector
d−1
∏
i=0
ni
𝔽
(∏
d−1
i=0
ni)
p
surface
-dim hyper-rectangle
d
(n0, …, nd−1)
nk
the surface has hyper-planes
∏
i≠k
ni
vk
surface = v⊥
k
orthogonal complement
surface
-dim hyper-rectangle
d
(n0, …, nd−1)
nk
the surface has hyper-planes
∏
i≠k
ni
surface hyper-cubes
d−1
∑
k=0
∏
i≠k
ni
surface
-dim hyper-rectangle
d
(n0, …, nd−1)
nk
surface :=
d−1
∑
k=0
∏
i≠k
Ini
In := {0, …, n − 1}
surface
-dim hyper-rectangle
d
(n0, …, nd−1)
nk
surface :=
d−1
∑
k=0
∏
i≠k
Ini
In := {0, …, n − 1}
(Id ×
d−1
∏
i=0
Ini
)/ ∼
where (k0, x0) ∼ (k1, x1) := (k0 = k1 ∧ ∀k, k ≠ k0 → x0 k = x1 k)
But define it as
surface
-dim hyper-rectangle
d
(n0, …, nd−1)
nk
surface :=
d−1
∑
k=0
∏
i≠k
Ini
In := {0, …, n − 1}
(Id ×
d−1
∏
i=0
Ini
)/ ∼
where (k0, x0) ∼ (k1, x1) := (k0 = k1 ∧ ∀k, k ≠ k0 → x0 k = x1 k)
But define it as
hyper-cubes :=
d−1
∏
i=0
Ini
surface
-dim hyper-rectangle
d
(n0, …, nd−1)
nk
surface :=
In := {0, …, n − 1}
(Id ×
d−1
∏
i=0
Ini
)/ ∼
where (k0, x0) ∼ (k1, x1) := (k0 = k1 ∧ ∀k, k ≠ k0 → x0 k = x1 k)
hyper-cubes :=
d−1
∏
i=0
Ini
switch
surface → state
state →
switch :
switch
surface → state
state →
all-lamps-o
ff
-able
∃l ∈ surface
*
, foldr switch initstate l = 0
switch :
switch
surface → state
state →
switch :
(Id ×
d−1
∏
i=0
Ini
)/ ∼
𝔽
(∏
d−1
i=0
ni)
p
𝔽
(∏
d−1
i=0
ni)
p
switch
surface → state
state →
switch :
(Id ×
d−1
∏
i=0
Ini
)/ ∼
𝔽
(∏
d−1
i=0
ni)
p
𝔽
(∏
d−1
i=0
ni)
p
𝔽
(∏
d−1
i=0
ni)
p → →
+ :
fd
switch
surface → state
state →
switch :
(Id ×
d−1
∏
i=0
Ini
)/ ∼
𝔽
(∏
d−1
i=0
ni)
p
fd
switch
(Id ×
d−1
∏
i=0
Ini
)/ ∼
𝔽
(∏
d−1
i=0
ni)
p
surface state
fd
: |surface| |cube| matrix
Pj × on
𝔽
p
switch
(Id ×
d−1
∏
i=0
Ini
)/ ∼
𝔽
(∏
d−1
i=0
ni)
p
surface state
: |surface| |cube| matrix
Pj ×
fd
P0 := 0 :
𝔽
0×1
-dim hyper-rectangle
d
switch
: |surface| |cube| matrix
Pj ×
-dim hyper-rectangle
d
switch
⋮
-dim hyper-rectangle
d + 1
{
: |surface| |cube| matrix
Pj ×
switch
Pj
: |surface| |cube| matrix
Pj ×
switch
⋮
Pj
Pj+1 :=
I Pj O
⋮ ⋱
I O Pj
Pj
: |surface| |cube| matrix
Pj ×
: |surface| |cube| matrix
Pj ×
switch
⋮
Pj
Pj+1 :=
I Pj O
⋮ ⋱
I O Pj
Pj
switch
⋮
Pj
Pj+1 :=
I Pj O
⋮ ⋱
I O Pj
Pj
: |surface| |cube| matrix
Pj ×
switch
⋮
Pj
Pj+1 :=
I Pj O
⋮ ⋱
I O Pj
Pj
: |surface| |cube| matrix
Pj ×
switch
⋮
Pj
Pj+1 :=
I Pj O
⋮ ⋱
I O Pj
Pj
: |surface| |cube| matrix
Pj ×
switch
⋮
Pj
Pj+1 :=
I Pj O
⋮ ⋱
I O Pj
Pj
: |surface| |cube| matrix
Pj ×
switch
⋮
Pj
Pj+1 :=
I Pj O
⋮ ⋱
I O Pj
Pj
: |surface| |cube| matrix
Pj ×
switch
surface → state
state →
switch :
𝔽
(∏
d−1
i=0
ni)
p
𝔽
(∏
d−1
i=0
ni)
p
𝔽
(∏
d−1
i=0
ni)
p → →
+ :
fd
switch
surface → state
state →
switch :
𝔽
(∏
d−1
i=0
ni)
p
𝔽
(∏
d−1
i=0
ni)
p
𝔽
(∏
d−1
i=0
ni)
p → →
+ :
fd
all-lamps-o
ff
-able
∃l ∈ surface
*
, foldr switch initstate l = 0
switch
surface → state
state →
switch :
𝔽
(∏
d−1
i=0
ni)
p
𝔽
(∏
d−1
i=0
ni)
p
𝔽
(∏
d−1
i=0
ni)
p → →
+ :
fd
all-lamps-o
ff
-able
∃l ∈ surface
*
, foldr switch initstate l = 0
∃l ∈ surface
*
,
∑
x∈l
fd l + initstate = 0
↔
switch
all-lamps-o
ff
-able
∃l ∈ surface
*
, foldr switch initstate l = 0
↔
↔
∃l ∈ surface
*
,
∑
x∈l
fd l + initstate = 0
∃g ∈ surface → ℕ,
∑
x
g x * fd x = − initstate
switch
all-lamps-o
ff
-able
∃l ∈ surface
*
, foldr switch initstate l = 0
↔
↔
∃l ∈ surface
*
,
∑
x∈l
fd l + initstate = 0
∃g ∈ surface → ℕ,
∑
x
g x * fd x = − initstate
linear space
switch
all-lamps-o
ff
-able
∃l ∈ surface
*
, foldr switch initstate l = 0
↔
↔
∃l ∈ surface
*
,
∑
x∈l
fd l + initstate = 0
∃g ∈ surface → ℕ,
∑
x
g x * fd x = − initstate
linear space
ℕ
∀x ∈ K, ∃n ∈ ℕ, x = n * 1K
∃p : prime, K ∼
𝔽
p ↔
switch
all-lamps-o
ff
-able
∃l ∈ surface
*
, foldr switch initstate l = 0
↔
↔
∃l ∈ surface
*
,
∑
x∈l
fd l + initstate = 0
∃g ∈ surface → ℕ,
∑
x
g x * fd x = − initstate
↔ initstate ∈ < Pd >
switch
all-lamps-o
ff
-able ↔ initstate ∈ < Pd >
Pj+1 :=
P0 := 0 :
𝔽
0×1
I Pj O
⋮ ⋱
I O Pj
switch
all-lamps-o
ff
-able ↔ initstate ∈ < Pd >
P0 := 0 :
𝔽
0×1
<
I Pj O
⋮ ⋱
I O Pj
I O ⋯ O
>
linearly independent
<
I Pj O
⋮ ⋱
I O Pj
> =
Pj+1 :=
I Pj O
⋮ ⋱
I O Pj
switch
all-lamps-o
ff
-able ↔ initstate ∈ < Pd >
P0 := 0 :
𝔽
0×1
I Pj O
⋮ ⋱
I O Pj
I O ⋯ O
Pj+1 :=
switch
all-lamps-o
ff
-able ↔ initstate ∈ < Pd >
P0 := 0 :
𝔽
0×1
I Pj O
⋮ ⋱
I O Pj
I O ⋯ O
Pj+1 := dim < Pj+1 > =
j
∏
i=0
ni + (nj+1 − 1)dim < Pj >
dim < P0 > = 0
all-lamps-o
ff
-able ↔ initstate ∈ < Pd >
P0 := 0 :
𝔽
0×1
p
I Pj O
⋮ ⋱
I O Pj
I O ⋯ O
Pj+1 :=
dim < Pd > =
d−1
∏
i=0
ni −
d−1
∏
i=0
(ni − 1)
dim < Pj+1 > =
j
∏
i=0
ni + (nj+1 − 1)dim < Pj >
dim < P0 > = 0
switch
Coq
hyper-cubes :=
d−1
∏
i=0
Ini
Definition hyperspace (s:seq nat) :=
foldr (fun n T => prod_finType (ordinal_finType n) T) unit_finType s.
(* foldr (prod o ordinal) unit s *)
list of lengths of hyper-rectangle
Coq
list of lengths of hyper-rectangle
surface := (Id ×
d−1
∏
i=0
Ini
)/ ∼
Definition surface (s:seq nat) :=
prod_finType (ordinal_finType (size s)) (hyperspace s).
(* 'I_(size s) * hyperspace s *)
Coq
list of lengths of hyper-rectangle
surface := (Id ×
d−1
∏
i=0
Ini
)/ ∼
Definition surface (s:seq nat) :=
prod_finType (ordinal_finType (size s)) (hyperspace s).
(* 'I_(size s) * hyperspace s *)
Definition reachable (s:seq nat) (init:state s) : Prop :=
exists p:seq (surface s), execute p init = [ffun => 0%R].
∃x ∈ X/ ∼ , P x ↔ ∃x ∈ X, P x
: well-de
fi
ned
P : X/ ∼ → 2 →
Coq
Variable (K:fieldType).
Definition state (s:seq nat) : Type := {ffun hyperspace s -> K}.
Definition cyclic_K := forall x:K, exists n, x = (n%:R)%R.
(* Hcyclic K <-> #| K | is prime i.e. K ~ F_p *)
Coq
surface → state
state →
switch :
Fixpoint switch_rec (s:seq nat) (n:nat) :
hyperspace s -> state s -> state s :=
match s,n return hyperspace s -> state s -> state s with
| [::], _ => fun _ => id
| _ :: s', 0 => fun c t =>
[ffun x => if (x.2 == c.2) then (t x + 1)%R else t x]
| _ :: s', n'.+1 => fun c t =>
[ffun x =>
if x.1 == c.1
then switch_rec n' c.2 [ffun y => t (x.1,y)] x.2
else t x]
end.
Definition switch (s:seq nat) (b:surface s) : state s -> state s :=
switch_rec b.1 b.2.
Coq
Definition execute (s:seq nat) (p:seq (surface s)) : state s -> state s :=
foldr (comp o @switch _) id p.
Definition reachable (s:seq nat) (init:state s) : Prop :=
exists p:seq (surface s), execute p init = [ffun => 0%R].
all-lamps-o
ff
-able
Coq
vectType
state →
Definition state2vec (s:seq nat) (t:state s) :
exp_vectType _ (foldr muln 1 s) := exp2v [ffun x => t (ord2hyperspace x)].
Coq
vectType
state →
Definition state2vec (s:seq nat) (t:state s) :
exp_vectType _ (foldr muln 1 s) := exp2v [ffun x => t (ord2hyperspace x)].
Fixpoint ord2hyperspace (s:seq nat) : 'I_(foldr muln 1 s) -> hyperspace s :=
match s return 'I_(foldr muln 1 s) -> hyperspace s with
| [::] => fun => tt
| _ :: _ => fun x => let: (x1, x2) := unmulord x in (x1, ord2hyperspace x2)
end.
I∏
d−1
i=0
ni
→
d−1
∏
i=0
Ini
Coq
vectType
state →
Definition state2vec (s:seq nat) (t:state s) :
exp_vectType _ (foldr muln 1 s) := exp2v [ffun x => t (ord2hyperspace x)].
Lemma state2vecK (s:seq nat): cancel (@state2vec s) (@vec2state _).
Lemma vec2stateK (s:seq nat): cancel (@vec2state s) (@state2vec _).
Coq
vectType
surface →
Fixpoint surface2state_rec (s:seq nat) (n:nat) : hyperspace s -> state s :=
match s,n return hyperspace s -> state s with
| [::], _ => fun _ => [ffun => 0%R]
| _ :: s', 0 => fun c => [ffun x => if (x.2 == c.2) then 1%R else 0%R]
| _ :: s', n'.+1 => fun c =>
[ffun x => if (x.1 == c.1)
then surface2state_rec n' c.2 x.2 else 0%R]
end.
Definition surface2state (s:seq nat) (c:surface s) : state s :=
surface2state_rec c.1 c.2.
Notation surface2vec c := (state2vec (surface2state c)).
Coq
Lemma state2vec_switch (s:seq nat) (c:surface s) (t:state s):
state2vec (switch c t) = (state2vec t + surface2vec c)%R.
Coq
Lemma state2vec_switch (s:seq nat) (c:surface s) (t:state s):
state2vec (switch c t) = (state2vec t + surface2vec c)%R.
Definition vreachable' (s:seq nat) (init:state s) :=
exists (p:seq (surface s)),
(sum_(c <- p) surface2vec c + state2vec init)%R = 0%R.
Lemma reachableP' (s:seq nat) (init:state s) :
reachable init <-> vreachable' init.
Coq
Definition vreachable (s:seq nat) (init:state s) :=
state2vec init in (sum_(c in surface s) <[surface2vec c]>)%VS.
Lemma vreachableP (s:seq nat) (init:state s):
cyclic_K -> reflect (vreachable' init) (vreachable init).
Coq
Definition vreachable (s:seq nat) (init:state s) :=
state2vec init in (sum_(c in surface s) <[surface2vec c]>)%VS.
Lemma vreachableP (s:seq nat) (init:state s):
cyclic_K -> reflect (vreachable' init) (vreachable init).
Coq
Fixpoint statebasis (s:seq nat) : seq (state s) :=
match s return seq (state s) with
| [::] => [::]
| n :: s' => (if n is S _
then codom (fun c => [ffun x => if x.2 == c then 1%R else 0%R])
else [::])
++ flatten
[seq map
(fun f:state s' =>
[ffun x => if val x.1 == i then f x.2 else 0%R])
(statebasis s') | i <- iota 0 n.-1]
end.
Notation basis s := [seq state2vec x | x <- statebasis s].
Coq
Definition tppmark_1 (s:seq nat):
cyclic_K -> forall init:state s,
reflect (reachable init) (state2vec init in <<basis s>>%VS) :=
fun Hc init => basis_reachable init Hc.
Coq
Definition tppmark_2 (s:seq nat): free (basis s) := free_basis _.
Coq
Definition tppmark_3 (s:seq nat):
dim <<basis s>> = prod_(n <- s) n - prod_(n <- s) n.-1 := dim_basis _.
dim < Pd > =
d−1
∏
i=0
ni −
d−1
∏
i=0
(ni − 1)
Coq
Definition tppmark_3 (s:seq nat):
dim <<basis s>> = prod_(n <- s) n - prod_(n <- s) n.-1 := dim_basis _.
Definition tppmark_2 (s:seq nat): free (basis s) := free_basis _.
Definition tppmark_1 (s:seq nat):
cyclic_K -> forall init:state s,
reflect (reachable init) (state2vec init in <<basis s>>%VS) :=
fun Hc init => basis_reachable init Hc.
Qiitaによる解説記事

TPPmark2025 Kenta Inoue's answer 12/04/2025