Review finding: Embedding only required back (emb i) = some i, which allows back to map a second tape onto a used one; such a lift would overwrite a tape the docs call untouched. Add emb_back, so back j = some i only when emb i = j, and prove it for castLE and skipOne. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diff
1 files changed +21 -1
| @@ -18,11 +18,14 @@ | ||
| 18 | 18 | namespace PvsNP |
| 19 | 19 | |
| 20 | 20 | /-- 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. -/ | |
| 22 | 24 | structure Embedding (k k' : Nat) where |
| 23 | 25 | emb : Fin (k + 1) → Fin (k' + 1) |
| 24 | 26 | back : Fin (k' + 1) → Option (Fin (k + 1)) |
| 25 | 27 | back_emb : ∀ i, back (emb i) = some i |
| 28 | + emb_back : ∀ j i, back j = some i → emb i = j | |
| 26 | 29 | |
| 27 | 30 | namespace Embedding |
| 28 | 31 | |
| @@ -31,6 +34,10 @@ | ||
| 31 | 34 | emb i := ⟨i.val, by omega⟩ |
| 32 | 35 | back j := if hj : j.val < k + 1 then some ⟨j.val, hj⟩ else none |
| 33 | 36 | 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 | |
| 34 | 41 | |
| 35 | 42 | /-- Tape `0` stays; tape `i + 1` becomes tape `i + 2`. Tape `1` is not used. -/ |
| 36 | 43 | def skipOne {k k' : Nat} (h : k + 1 ≤ k') : Embedding k k' where |
| @@ -48,6 +55,19 @@ | ||
| 48 | 55 | have h3 : i.val + 1 - 1 < k + 1 := by omega |
| 49 | 56 | simp only [hi, h1, h2, h3, ↓reduceIte, ↓reduceDIte, Option.some.injEq] |
| 50 | 57 | 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 | |
| 51 | 71 | |
| 52 | 72 | end Embedding |
| 53 | 73 | |