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
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
19.
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
20.
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
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
Coq
list of lengthsof 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 *)
52.
Coq
list of lengthsof 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 →
53.
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 *)
54.
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.
55.
Coq
Definition execute (s:seqnat) (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
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
Fixpoint statebasis (s:seqnat) : 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].
65.
Coq
Definition tppmark_1 (s:seqnat):
cyclic_K -> forall init:state s,
reflect (reachable init) (state2vec init in <<basis s>>%VS) :=
fun Hc init => basis_reachable init Hc.