changes / #1 2223d32c5d1661da557e69b56124a9a1

Examples: concrete one-step machines for first-symbol languages

openjp_ee76fd26… → mainrev 2+163 -356d ago

Copy for your agent

Paste it to your agent. It points at this project's page for agents, which says the rest.

Needs attention

auto-land refusedthe reasons are under Landing, below

Roadmap milestone 2. Adds `PvsNP/Examples/FirstSymbol.lean`: a three-state, one-tape machine that reads the cell under the head once and halts, accepting when a test `p` on that symbol passes. Proved: it decides `{x | p x.head? = true}` in one step, so every such language is in P (`Examples.firstSymbol_inP`). Instances over `Bool`: words starting with `true`, the empty word, and the non-empty words (via closure under complement). An `example` runs the machine on `[true, false]` and checks it accepts. Also: the theorem joins the axiom audit, and README/ROADMAP mark the milestone done. Checked: `lake build` passes on the head (library + axiom audit); no `sorry`; `firstSymbol_inP` depends only on `propext`, `Classical.choice`, `Quot.sound`.

Landing

auto-land refusedby rule examples-first-symbolrev 26d ago
this change was opened without a branch; the rule takes only changes pushed from examples/first-symbol

Landing rules

examples-first-symbolrefused: the reasons are under Landing, abovelake-build passedlands by itself
modified Audit/Axioms.leanmodified PvsNP.leanmodified PvsNP/Complexity/NP.leanmodified PvsNP/Complexity/P.leanmodified PvsNP/Complexity/Reduction.leanadded PvsNP/Examples/FirstSymbol.leanmodified PvsNP/Machine/Defs.leanmodified PvsNP/Machine/Lift.leanmodified README.mdmodified ROADMAP.mdreported by jp_72b535ee9c73365d4010be4167c0754535b843c26c52baa6b06489303691f0c7
GET https://git.neoopensource.com/v1/repos/pvsnp/landing-rules

Checks

passedindependent-reviewrev 2Codex gpt-6.2-astra, 2 rounds: 1 HIGH fixed, 1 HIGH refuted, 2 MEDIUM fixed; approve
passedlake-buildrev 2exit 0 in 6.4 s

Reviews

No reviews yet.

Revisions (2)

rev 268ee862ejp_ee76fd26… · 6d agointerdiff 1→2
rev 1396d8a0djp_ee76fd26… · 6d ago

Diff · rev 2

10 files changed +163 -35
@@ -63,3 +63,9 @@
6363 /-- info: 'PvsNP.Machine.run_seq' depends on axioms: [propext, Quot.sound] -/
6464 #guard_msgs in
6565 #print axioms PvsNP.Machine.run_seq
66+
67+/--
68+info: 'PvsNP.Examples.firstSymbol_inP' depends on axioms: [propext, Classical.choice, Quot.sound]
69+-/
70+#guard_msgs in
71+#print axioms PvsNP.Examples.firstSymbol_inP
M PvsNP.lean +1 -0
@@ -11,6 +11,7 @@
1111 import PvsNP.Complexity.NP
1212 import PvsNP.Complexity.Completeness
1313 import PvsNP.Open
14+import PvsNP.Examples.FirstSymbol
1415
1516 /-! # P versus NP in Lean 4
1617
@@ -3,12 +3,17 @@
33 /-!
44 # The class NP
55
6-`InNP L`: some machine verifies `L` in polynomial time. The input `x` is on tape `0` and a certificate
6+`InNP L`: the alphabet is finite and some machine verifies `L` in polynomial time. The input `x` is on tape `0` and a certificate
77 `w` on tape `1`; the verifier halts within `T |x|` steps whatever the certificate, and `x ∈ L` exactly
88 when some certificate makes it accept. Because the time bound depends on `|x|` alone, only the first
99 `T |x|` symbols of a certificate can matter, so certificates are polynomially short in effect
1010 (Sipser, *Introduction to the Theory of Computation*, Definition 7.18).
1111
12+Certificates are written over the input alphabet. For finite alphabets with at least two symbols this
13+is the usual NP. Over a one-symbol alphabet a certificate carries only its length: certificates are
14+unary rather than binary, so `InNP` there uses a different certificate model from the usual one for
15+unary languages. The open problem is stated over `Bool`.
16+
1217 Proved here:
1318 - `InP.inNP`: **P ⊆ NP**. A decider, run with tape `1` left alone, is a verifier that ignores its
1419 certificate.
@@ -22,27 +27,27 @@
2227
2328 /-- `L ∈ NP`: a machine verifies `L` in polynomial time. -/
2429 def InNP (L : Language α) : Prop :=
25- ∃ (k : Nat) (M : Machine α k) (T : Nat → Nat), PolyBounded T ∧ VerifiesIn M L T
30+ IsFinite α ∧ ∃ (k : Nat) (M : Machine α k) (T : Nat → Nat), PolyBounded T ∧ VerifiesIn M L T
2631
2732 namespace InNP
2833
2934 /-- The time bound of a verifier can be taken of the form `c * (n + 1) ^ d`, hence monotone. -/
3035 theorem polyBound {L : Language α} (h : InNP L) :
3136 ∃ (k : Nat) (M : Machine α k) (c d : Nat), VerifiesIn M L (PvsNP.polyBound c d) := by
32- obtain ⟨k, M, T, ⟨c, d, hT⟩, hM⟩ := h
37+ obtain ⟨_, k, M, T, ⟨c, d, hT⟩, hM⟩ := h
3338 exact ⟨k, M, c, d, hM.mono hT⟩
3439
3540 end InNP
3641
3742 /-- **P ⊆ NP.** -/
3843 theorem InP.inNP {L : Language α} (h : InP L) : InNP L := by
39- obtain ⟨k, M, T, hT, hM⟩ := h
44+ obtain ⟨hα, k, M, T, hT, hM⟩ := h
4045 let E := Embedding.skipOne (Nat.le_refl (k + 1))
4146 have e : ∀ x w, (M.lift E).init (verifierTapes x w) =
4247 M.liftCfg E (verifierTapes x w) (M.init (inputTapes x)) := by
4348 intro x w
4449 simp only [Machine.init, Machine.liftCfg, E, liftTapes_skipOne_inputTapes]; rfl
45- refine ⟨k + 1, M.lift E, T, hT, fun x w => ?_, fun x => ?_⟩
50+ refine ⟨hα, k + 1, M.lift E, T, hT, fun x w => ?_, fun x => ?_⟩
4651 · rw [e, Machine.run_lift]; exact (hM x).1
4752 · simp only [e, Machine.run_lift]
4853 exact ⟨fun hx => ⟨[], (hM x).2.mpr hx⟩, fun ⟨_, hw⟩ => (hM x).2.mp hw⟩
@@ -93,7 +98,7 @@
9398 (PvsNP.polyBound c₂ d₂ (f x).length)) := fun x w =>
9499 Machine.run_seq_verifier M₁ hk₁ V' hM₁ x w _ _ (hV'.1 (f x) w)
95100 (Nat.add_le_add_left (polyBound.mono c₂ d₂ (hB x)) _)
96- refine ⟨k₁ + k₂ + 1, (M₁.lift (Embedding.skipOne hk₁)).seq V', T, ?_, fun x w => ?_, fun x => ?_⟩
101+ refine ⟨hf.1, k₁ + k₂ + 1, (M₁.lift (Embedding.skipOne hk₁)).seq V', T, ?_, fun x w => ?_, fun x => ?_⟩
97102 · exact ((PolyBounded.polyBound c₁ d₁).add (PolyBounded.const 1)).add
98103 ((PolyBounded.polyBound c₂ d₂).comp (PolyBounded.polyBound b e))
99104 · rw [key]; exact hV'.1 (f x) w
@@ -4,7 +4,10 @@
44 /-!
55 # The class P
66
7-`InP L`: some multi-tape machine decides `L` within a polynomial number of steps.
7+`InP L`: the alphabet is finite and some multi-tape machine decides `L` within a polynomial number
8+of steps. Finiteness of the alphabet is part of the definition: over an infinite alphabet a single
9+symbol carries unbounded information (a machine reading one `Nat` could test membership in the
10+halting set), so P is empty there by definition rather than meaningless.
811
912 Proved here: the full and the empty language are in P, and P is closed under complement.
1013 -/
@@ -13,9 +16,9 @@
1316
1417 variable {α : Type}
1518
16-/-- `L ∈ P`: a machine decides `L` in polynomial time. -/
19+/-- `L ∈ P`: over a finite alphabet, a machine decides `L` in polynomial time. -/
1720 def InP (L : Language α) : Prop :=
18- ∃ (k : Nat) (M : Machine α k) (T : Nat → Nat), PolyBounded T ∧ DecidesIn M L T
21+ IsFinite α ∧ ∃ (k : Nat) (M : Machine α k) (T : Nat → Nat), PolyBounded T ∧ DecidesIn M L T
1922
2023 /-- A machine that halts at once, accepting or not as `b` says, touching nothing. -/
2124 def Machine.const (α : Type) (k : Nat) (b : Bool) : Machine α k where
@@ -31,21 +34,24 @@
3134 /-- The time bound of a language in P can be taken of the form `c * (n + 1) ^ d`, hence monotone. -/
3235 theorem polyBound {L : Language α} (h : InP L) :
3336 ∃ (k : Nat) (M : Machine α k) (c d : Nat), DecidesIn M L (PvsNP.polyBound c d) := by
34- obtain ⟨k, M, T, ⟨c, d, hT⟩, hM⟩ := h
37+ obtain ⟨_, k, M, T, ⟨c, d, hT⟩, hM⟩ := h
3538 exact ⟨k, M, c, d, hM.mono hT⟩
3639
37-theorem univ : InP (Language.univ : Language α) :=
38- ⟨0, Machine.const α 0 true, fun _ => 0, PolyBounded.const 0, fun _ =>
40+/-- Only languages over finite alphabets are in P. -/
41+theorem isFinite {L : Language α} (h : InP L) : IsFinite α := h.1
42+
43+theorem univ [IsFinite α] : InP (Language.univ : Language α) :=
44+ ⟨inferInstance, 0, Machine.const α 0 true, fun _ => 0, PolyBounded.const 0, fun _ =>
3945 ⟨rfl, by simp [Machine.const, Language.univ, Machine.init]⟩⟩
4046
41-theorem empty : InP (Language.empty : Language α) :=
42- ⟨0, Machine.const α 0 false, fun _ => 0, PolyBounded.const 0, fun _ =>
47+theorem empty [IsFinite α] : InP (Language.empty : Language α) :=
48+ ⟨inferInstance, 0, Machine.const α 0 false, fun _ => 0, PolyBounded.const 0, fun _ =>
4349 ⟨rfl, by simp [Machine.const, Language.empty, Machine.init]⟩⟩
4450
4551 /-- **P is closed under complement**: swap accepting and rejecting halted states. -/
4652 theorem compl {L : Language α} (h : InP L) : InP L.compl := by
47- obtain ⟨k, M, T, hT, hM⟩ := h
48- refine ⟨k, M.withAccepting (fun q => !M.accepting q), T, hT, fun x => ?_⟩
53+ obtain ⟨hα, k, M, T, hT, hM⟩ := h
54+ refine ⟨hα, k, M.withAccepting (fun q => !M.accepting q), T, hT, fun x => ?_⟩
4955 have e : (M.withAccepting (fun q => !M.accepting q)).init (inputTapes x) = M.init (inputTapes x) :=
5056 rfl
5157 rw [e, Machine.run_withAccepting]
@@ -54,8 +60,8 @@
5460 ← (hM x).2, Bool.not_eq_true]
5561
5662 theorem of_compl {L : Language α} (h : InP L.compl) : InP L := by
57- obtain ⟨k, M, T, hT, hM⟩ := h.compl
58- exact ⟨k, M, T, hT, fun x => ⟨(hM x).1, by rw [(hM x).2, Language.compl_compl]⟩⟩
63+ obtain ⟨hα, k, M, T, hT, hM⟩ := h.compl
64+ exact ⟨hα, k, M, T, hT, fun x => ⟨(hM x).1, by rw [(hM x).2, Language.compl_compl]⟩⟩
5965
6066 theorem compl_iff {L : Language α} : InP L.compl ↔ InP L := ⟨of_compl, compl⟩
6167
@@ -3,7 +3,7 @@
33 /-!
44 # Polynomial-time reductions
55
6-`PolyTimeComputable f`: a machine computes `f` in polynomial time, and `|f x|` is polynomially bounded
6+`PolyTimeComputable f`: the alphabet is finite and a machine computes `f` in polynomial time, and `|f x|` is polynomially bounded
77 in `|x|`. (The output bound follows from the time bound in any reasonable model; we state it rather
88 than derive it. Deriving it is on the roadmap.)
99
@@ -19,7 +19,7 @@
1919
2020 /-- `f` is computable in polynomial time, with polynomially bounded output. -/
2121 def PolyTimeComputable (f : List α → List α) : Prop :=
22- ∃ (k : Nat) (M : Machine α k) (T B : Nat → Nat), PolyBounded T ∧ PolyBounded B ∧
22+ IsFinite α ∧ ∃ (k : Nat) (M : Machine α k) (T B : Nat → Nat), PolyBounded T ∧ PolyBounded B ∧
2323 ComputesIn M f T ∧ ∀ x, (f x).length ≤ B x.length
2424
2525 /-- `L` many-one reduces to `L'` in polynomial time. -/
@@ -83,12 +83,12 @@
8383 theorem normalize {f : List α → List α} (h : PolyTimeComputable f) :
8484 ∃ (k : Nat) (M : Machine α k) (c d b e : Nat), ComputesIn M f (polyBound c d) ∧
8585 ∀ x, (f x).length ≤ polyBound b e x.length := by
86- obtain ⟨k, M, T, B, ⟨c, d, hT⟩, ⟨b, e, hB⟩, hM, hfB⟩ := h
86+ obtain ⟨_, k, M, T, B, ⟨c, d, hT⟩, ⟨b, e, hB⟩, hM, hfB⟩ := h
8787 exact ⟨k, M, c, d, b, e, hM.mono hT, fun x => Nat.le_trans (hfB x) (hB _)⟩
8888
8989 /-- The identity: the machine that halts at once. -/
90-theorem id : PolyTimeComputable (fun x : List α => x) :=
91- ⟨0, Machine.const α 0 true, fun _ => 0, fun n => n, PolyBounded.const 0, PolyBounded.id,
90+theorem id [IsFinite α] : PolyTimeComputable (fun x : List α => x) :=
91+ ⟨inferInstance, 0, Machine.const α 0 true, fun _ => 0, fun n => n, PolyBounded.const 0, PolyBounded.id,
9292 fun _ => ⟨rfl, rfl⟩, fun _ => Nat.le_refl _⟩
9393
9494 /-- **Polynomial-time functions compose.** -/
@@ -98,7 +98,7 @@
9898 obtain ⟨k₂, M₂, c₂, d₂, b₂, e₂, hM₂, hB₂⟩ := hg.normalize
9999 have hl₁ := hM₁.lift (Nat.le_add_right k₁ k₂)
100100 have hl₂ := hM₂.lift (Nat.le_add_left k₂ k₁)
101- refine ⟨k₁ + k₂, _, _, fun n => polyBound b₂ e₂ (polyBound b₁ e₁ n),
101+ refine ⟨hf.1, k₁ + k₂, _, _, fun n => polyBound b₂ e₂ (polyBound b₁ e₁ n),
102102 ?_, ?_, hl₁.seq hB₁ hl₂, fun x => ?_⟩
103103 · exact ((PolyBounded.polyBound c₁ d₁).add (PolyBounded.const 1)).add
104104 ((PolyBounded.polyBound c₂ d₂).comp (PolyBounded.polyBound b₁ e₁))
@@ -110,7 +110,7 @@
110110 namespace Reduces
111111
112112 /-- `≤ₚ` is reflexive. -/
113-theorem refl (L : Language α) : L ≤ₚ L := ⟨_, PolyTimeComputable.id, fun _ => Iff.rfl⟩
113+theorem refl [IsFinite α] (L : Language α) : L ≤ₚ L := ⟨_, PolyTimeComputable.id, fun _ => Iff.rfl⟩
114114
115115 /-- **Reductions compose**: `≤ₚ` is transitive. -/
116116 theorem trans {L₁ L₂ L₃ : Language α} (h₁₂ : L₁ ≤ₚ L₂) (h₂₃ : L₂ ≤ₚ L₃) : L₁ ≤ₚ L₃ := by
@@ -131,7 +131,7 @@
131131 obtain ⟨k₁, M₁, c₁, d₁, b, e, hM₁, hB⟩ := hf.normalize
132132 obtain ⟨k₂, M₂, c₂, d₂, hM₂⟩ := hL'.polyBound
133133 have hd := DecidesIn.seq (hM₁.lift (Nat.le_add_right k₁ k₂)) hB (hM₂.lift (Nat.le_add_left k₂ k₁))
134- refine ⟨k₁ + k₂,
134+ refine ⟨hL'.1, k₁ + k₂,
135135 (M₁.lift (Embedding.castLE (Nat.le_add_right k₁ k₂))).seq
136136 (M₂.lift (Embedding.castLE (Nat.le_add_left k₂ k₁))),
137137 fun n => PvsNP.polyBound c₁ d₁ n + 1 + PvsNP.polyBound c₂ d₂ (PvsNP.polyBound b e n), ?_, ?_⟩
@@ -0,0 +1,81 @@
1+import PvsNP.Complexity.P
2+
3+/-!
4+# Example: languages decided by the first symbol
5+
6+A concrete machine, not a construction from other machines: it reads the cell under the head of tape
7+`0` once and halts, accepting when a test `p` on that symbol passes. It decides
8+`{x | p x.head? = true}` in one step, so each such language is in P.
9+
10+The machine and its one-step run work over any alphabet; only the conclusion `InP` needs a finite
11+one (over `Nat`, a test on one symbol could be the halting problem). Two instances over `Bool`: the words that start with `true`, and the empty word.
12+-/
13+
14+namespace PvsNP.Examples
15+
16+variable {α : Type}
17+
18+/-- The machine's three states. -/
19+inductive FirstSymbolState where
20+ | start
21+ | accept
22+ | reject
23+ deriving DecidableEq, Repr
24+
25+instance : IsFinite FirstSymbolState :=
26+ ⟨⟨[.start, .accept, .reject], by intro a; cases a <;> simp⟩⟩
27+
28+/-- The language of words whose first symbol (`none` for the empty word) passes `p`. -/
29+def FirstSymbol (p : Option α → Bool) : Language α := fun x => p x.head? = true
30+
31+/-- Read tape `0` once; accept if `p` holds of what is there. One step, one tape. -/
32+def firstSymbolMachine (p : Option α → Bool) : Machine α 0 where
33+ Q := FirstSymbolState
34+ finite := inferInstance
35+ start := .start
36+ halted
37+ | .start => false
38+ | _ => true
39+ accepting
40+ | .accept => true
41+ | _ => false
42+ δ _ r := (if p (r 0) then .accept else .reject, r, fun _ => .stay)
43+
44+/-- After one step the machine has halted, in `accept` exactly when `p` holds of the first symbol. -/
45+theorem firstSymbolMachine_run (p : Option α → Bool) (x : List α) :
46+ ((firstSymbolMachine p).run ((firstSymbolMachine p).init (inputTapes x)) 1).state =
47+ if p x.head? then .accept else .reject := by
48+ simp [Machine.run, Machine.step, Machine.init, firstSymbolMachine, Machine.reads, inputTapes,
49+ Tape.read_ofWord]
50+
51+/-- Every language decided by the first symbol is in P, within one step. -/
52+theorem firstSymbol_inP [IsFinite α] (p : Option α → Bool) : InP (FirstSymbol p) := by
53+ refine ⟨inferInstance, 0, firstSymbolMachine p, fun _ => 1, PolyBounded.const 1, fun x => ?_⟩
54+ rw [firstSymbolMachine_run]
55+ cases h : p x.head? <;> simp [firstSymbolMachine, FirstSymbol, h]
56+
57+/-- Words over `Bool` that start with `true`. -/
58+def StartsWithTrue : Language Bool := FirstSymbol (· == some true)
59+
60+theorem startsWithTrue_iff (x : List Bool) : StartsWithTrue x ↔ x.head? = some true := by
61+ simp [StartsWithTrue, FirstSymbol]
62+
63+theorem startsWithTrue_inP : InP StartsWithTrue := firstSymbol_inP _
64+
65+/-- The language holding only the empty word. -/
66+def EmptyWord : Language Bool := FirstSymbol Option.isNone
67+
68+theorem emptyWord_iff (x : List Bool) : EmptyWord x ↔ x = [] := by
69+ cases x <;> simp [EmptyWord, FirstSymbol]
70+
71+theorem emptyWord_inP : InP EmptyWord := firstSymbol_inP _
72+
73+/-- Its complement, the non-empty words, is in P too, by closure under complement. -/
74+theorem nonEmpty_inP : InP EmptyWord.compl := emptyWord_inP.compl
75+
76+/-- The machine run in the kernel: on `[true, false]` it accepts after one step. -/
77+example : ((firstSymbolMachine (· == some true)).run
78+ ((firstSymbolMachine (· == some true)).init (inputTapes [true, false])) 1).state = .accept := by
79+ rw [firstSymbolMachine_run]; rfl
80+
81+end PvsNP.Examples
@@ -16,8 +16,9 @@
1616 - The tape alphabet is `Option α`: machines have no extra work symbols. For `|α| ≥ 2` this changes
1717 running times only polynomially; it keeps machines over one alphabet composable without re-encoding
1818 tapes.
19-- Finiteness of `Q` is part of the structure (`finite`). Without it a state could store the whole input
20- and the model would decide anything in one step.
19+- Finiteness of `Q` is part of the structure (`finite`). Without it a machine could scan its input
20+ once, accumulating it in the state, and then apply an arbitrary predicate: every language would be
21+ decidable in linear time. The alphabet's finiteness is required by the complexity classes.
2122 -/
2223
2324 namespace PvsNP
@@ -18,11 +18,14 @@
1818 namespace PvsNP
1919
2020 /-- How the tapes of a `k + 1`-tape machine sit among `k' + 1` tapes: `emb` places each small tape,
21-and `back` recognises the places (`none` for a tape the small machine does not use). -/
21+and `back` recognises the places (`none` for a tape the small machine does not use). The two laws
22+make `back` exactly the inverse of `emb` on its image, so `emb` is injective and every tape outside
23+the image is left alone. -/
2224 structure Embedding (k k' : Nat) where
2325 emb : Fin (k + 1) → Fin (k' + 1)
2426 back : Fin (k' + 1) → Option (Fin (k + 1))
2527 back_emb : ∀ i, back (emb i) = some i
28+ emb_back : ∀ j i, back j = some i → emb i = j
2629
2730 namespace Embedding
2831
@@ -31,6 +34,10 @@
3134 emb i := ⟨i.val, by omega⟩
3235 back j := if hj : j.val < k + 1 then some ⟨j.val, hj⟩ else none
3336 back_emb i := by simp [i.isLt]
37+ emb_back j i h := by
38+ split at h
39+ · cases h; rfl
40+ · cases h
3441
3542 /-- Tape `0` stays; tape `i + 1` becomes tape `i + 2`. Tape `1` is not used. -/
3643 def skipOne {k k' : Nat} (h : k + 1 ≤ k') : Embedding k k' where
@@ -48,6 +55,19 @@
4855 have h3 : i.val + 1 - 1 < k + 1 := by omega
4956 simp only [hi, h1, h2, h3, ↓reduceIte, ↓reduceDIte, Option.some.injEq]
5057 exact Fin.ext (by simp)
58+ emb_back j i h := by
59+ apply Fin.ext
60+ by_cases h0 : j.val = 0
61+ · simp only [h0, ↓reduceIte, Option.some.injEq] at h
62+ subst h; simp [h0]
63+ · by_cases h1 : j.val = 1
64+ · simp [h1] at h
65+ · simp only [h0, h1, ↓reduceIte] at h
66+ split at h
67+ · cases h
68+ have : j.val - 1 ≠ 0 := by omega
69+ simp [this]; omega
70+ · cases h
5171
5272 end Embedding
5373
M README.md +10 -4
@@ -36,6 +36,7 @@
3636 | For NP-complete `L`: P ≠ NP ↔ `L ∉ P` | `NPComplete.pNeNP_iff` | [`Open.lean`](PvsNP/Open.lean) |
3737 | Running a machine on more tapes is a faithful simulation | `Machine.run_lift` | [`Machine/Lift.lean`](PvsNP/Machine/Lift.lean) |
3838 | Running two machines in sequence | `Machine.run_seq` | [`Machine/Compose.lean`](PvsNP/Machine/Compose.lean) |
39+| A concrete one-step machine: first-symbol languages are in P | `Examples.firstSymbol_inP` | [`Examples/FirstSymbol.lean`](PvsNP/Examples/FirstSymbol.lean) |
3940
4041 The statement of the open problem, verbatim from [`PvsNP/Open.lean`](PvsNP/Open.lean):
4142
@@ -78,6 +79,7 @@
7879 Complexity/NP.lean the class NP; P ⊆ NP; closure under reductions
7980 Complexity/Completeness.lean NP-hardness and NP-completeness
8081 Open.lean the P vs NP statement (open)
82+ Examples/FirstSymbol.lean concrete machines: languages decided by the first symbol
8183 Audit/Axioms.lean build-time axiom audit
8284 ```
8385
@@ -105,8 +107,10 @@
105107 These are deliberate, and each is a place where a reader should check that the definitions mean what
106108 they claim:
107109
108-- **Finite control.** A machine's state type must be finite (`IsFinite`). Without that, one state
109- could store the whole input and every language would be decidable in one step.
110+- **Finite control, finite alphabet.** A machine's state type must be finite (`IsFinite`): otherwise
111+ it could read its input into its state and then apply any predicate at all. P, NP and
112+ polynomial-time functions also require a finite alphabet: over `Nat`, a machine reading a single
113+ symbol could test membership in the halting set.
110114 - **Tape alphabet `Option α`.** Machines write input symbols or blanks, nothing else. For alphabets with
111115 at least two symbols this costs only a polynomial slowdown, and it lets machines over the same
112116 alphabet run one after another with no re-encoding.
@@ -115,7 +119,9 @@
115119 a literal hand-over.
116120 - **Verifiers in the style of Sipser.** The verifier's time bound depends on `|x|` only, and
117121 `x ∈ L ↔ ∃ w, V accepts (x, w)`. A verifier running `T |x|` steps can read at most `T |x|`
118- certificate symbols, so certificates are polynomially short in effect.
122+ certificate symbols, so certificates are polynomially short in effect. Certificates use the input
123+ alphabet: the usual NP over a finite alphabet of two or more symbols, while over a one-symbol
124+ alphabet certificates are unary rather than binary.
119125 - **Output bound stated, not derived.** `PolyTimeComputable f` asks for `|f x|` to be polynomially
120126 bounded. That follows from the time bound in any reasonable model; deriving it is on the roadmap.
121127
@@ -124,7 +130,7 @@
124130 The milestones, in order; details and acceptance criteria are in [`ROADMAP.md`](ROADMAP.md).
125131
126132 1. **Done:** machines, P, NP, reductions, P ⊆ NP, closure properties, NP-completeness, the open statement.
127-2. Examples: concrete machines for small languages, run in the kernel.
133+2. **Done:** examples: concrete machines for small languages, run in the kernel.
128134 3. Derive the output-length bound from the time bound.
129135 4. Short certificates suffice: verifiers only ever need certificates of length `≤ T |x|`.
130136 5. Boolean formulas, CNF and an encoding into `List Bool`.
M ROADMAP.md +4 -2
@@ -11,13 +11,15 @@
1111 statement. Proved: P ⊆ NP, P closed under complement, reductions reflexive and transitive, P and NP
1212 closed under reductions, an NP-complete language is in P iff P = NP.
1313
14-## 2. Examples
14+## 2. Examples — done
1515
1616 Concrete machines for small languages over `Bool` (the empty word, "starts with `true`"), with their
1717 time bounds proved by running them. Shows the definitions are inhabited by real machines, not only by
1818 constructions.
1919
20-Done when: at least two concrete languages are proved in P by explicit machines.
20+Done when: at least two concrete languages are proved in P by explicit machines. Done in
21+[`PvsNP/Examples/FirstSymbol.lean`](PvsNP/Examples/FirstSymbol.lean): "starts with `true`", the
22+empty word and the non-empty words, all from one machine that reads a single cell.
2123
2224 ## 3. Output length from running time
2325