Six-axis rotation and measurement controls
DefinitionAPFReachKernel_SpinControlapfconditional-referencereachkernel
The finite carrier has six signed axes. Supplied rotations and multivalued measurement tables generate word outcomes. Continuations retain a start tag, loads count word length and the model capacity is four. Readouts and sample alignments support the later order, movement and floor results. The interface describes this automaton; it supplies neither a quantum system nor an original physical cost model.
Definition code
import Definitions.Def_APFReachKernel_Bridge
import Definitions.Def_APFReachKernel_ContinuationModel
import Definitions.Def_APFReachKernel_Foundation
import Definitions.Def_APFReachKernel_RealignmentModel
namespace ReachKernel.SpinControl
end ReachKernel.SpinControl
/-
ReachKernel/SpinControl.lean
A supplied finite six-axis automaton with rotations and multivalued
measurement tables, tagged-start continuations, length load and budget4.
The model proves movement, order effects, composition and a carrier floor.
The family-blind bridge permits free changes of alignment labels at one
carrier. These facts concern this model and do not establish a full
foundation model, a quantum system, SU(2), or original physical bills.
-/
set_option autoImplicit false
namespace ReachKernel.SpinControl
inductive Ax | xp | xm | yp | ym | zp | zm
deriving DecidableEq, Repr
open Ax
inductive Op | Rx | Ry | Rz | Mx | My | Mz
deriving DecidableEq, Repr
open Op
/-- Outcomes of one operation. Rotations are quarter turns (right-hand rule
about the named axis); a measurement along the state's own axis is the
identity, a transverse measurement has two outcomes. -/
def outs : Ax → Op → List Ax
| yp, Rx => [zp] | zp, Rx => [ym] | ym, Rx => [zm] | zm, Rx => [yp] | a, Rx => [a]
| zp, Ry => [xp] | xp, Ry => [zm] | zm, Ry => [xm] | xm, Ry => [zp] | a, Ry => [a]
| xp, Rz => [yp] | yp, Rz => [xm] | xm, Rz => [ym] | ym, Rz => [xp] | a, Rz => [a]
| xp, Mx => [xp] | xm, Mx => [xm] | _, Mx => [xp, xm]
| yp, My => [yp] | ym, My => [ym] | _, My => [yp, ym]
| zp, Mz => [zp] | zm, Mz => [zm] | _, Mz => [zp, zm]
/-- Outcomes of a word, applied head first. -/
def outcomes : Ax → List Op → List Ax
| a, [] => [a]
| a, o :: w => (outs a o).flatMap (fun b => outcomes b w)
theorem outcomes_append (a : Ax) (w₁ w₂ : List Op) (u : Ax) :
u ∈ outcomes a (w₁ ++ w₂) ↔ ∃ b, b ∈ outcomes a w₁ ∧ u ∈ outcomes b w₂ := by
induction w₁ generalizing a with
| nil =>
simp [outcomes]
| cons o w ih =>
simp only [List.cons_append, outcomes, List.mem_flatMap]
constructor
· rintro ⟨b, hb, hu⟩
obtain ⟨c, hc, hu'⟩ := (ih b).1 hu
exact ⟨c, ⟨b, hb, hc⟩, hu'⟩
· rintro ⟨c, ⟨b, hb, hc⟩, hu⟩
exact ⟨b, hb, (ih b).2 ⟨c, hc, hu⟩⟩
/-- Step budget. -/
def B : Nat := 4
/-- A continuation records its start and its word. -/
abbrev Q := Ax × List Op
def cont : Ax → Set Q := fun a c => c.1 = a ∧ c.2.length ≤ B
def calib : Nat → Nat := fun n => n
def load (c : Q) : Nat := c.2.length
def concat (c' c : Q) : Q := (c.1, c.2 ++ c'.2)
theorem cont_inj (a b : Ax) (h : cont a = cont b) : a = b := by
have ha : ((a, ([] : List Op)) : Q) ∈ cont a := ⟨rfl, Nat.zero_le _⟩
rw [h] at ha
exact ha.1
theorem class_eq_iff (a b : Ax) : physicalClass cont a = physicalClass cont b ↔ a = b :=
⟨fun h => cont_inj a b ((physicalClass_eq_iff cont a b).1 h), fun h => h ▸ rfl⟩
def model : ContinuationModel cont calib B where
Reaches a c y := c.1 = a ∧ c.2.length ≤ B ∧ ∃ z, z ∈ outcomes a c.2 ∧ y = physicalClass cont z
load := load
concat := concat
reaches_descends := by
intro a a' c y h hr
rw [(class_eq_iff a a').1 h] at hr
exact hr
identity := fun a => ⟨(a, []), ⟨rfl, Nat.zero_le _⟩, rfl, Nat.zero_le _, a, by simp [outcomes], rfl⟩
concat_mem := by
intro a c c' y hc hr ha hb
obtain ⟨h1, _, z, _, rfl⟩ := hr
exact ⟨h1, hb⟩
concat_reaches := by
intro a c c' y w hc hr ha hb hall
obtain ⟨h1, _, z, hz, rfl⟩ := hr
have hc' : c' ∈ cont z := (availableAt_mk cont c' z).1 ha
obtain ⟨h1', _, u, hu, rfl⟩ := hall z rfl
refine ⟨h1, hb, u, ?_, rfl⟩
show u ∈ outcomes a (c.2 ++ c'.2)
rw [outcomes_append]
exact ⟨z, hz, h1' ▸ hu⟩
prefix_mem := by
intro a c c' h
obtain ⟨h1, h2⟩ := h
refine ⟨h1, ?_⟩
have h2' : (c.2 ++ c'.2).length ≤ B := h2
rw [List.length_append] at h2'
show c.2.length ≤ B
omega
/-! ### Raw-level facts, all by computation -/
/-! ### The alignment level, derived through the bridge -/
theorem hzero : ∀ a, ∃ e, e ∈ cont a ∧ model.Reaches a e (physicalClass cont a) ∧ calib (model.load e) = 0 :=
fun a => ⟨(a, []), ⟨rfl, Nat.zero_le _⟩, ⟨rfl, Nat.zero_le _, a, by simp [outcomes], rfl⟩, rfl⟩
theorem hP3 : ∀ c₁ c₂ : Q, calib (model.load (model.concat c₂ c₁)) ≤ calib (model.load c₁) + calib (model.load c₂) := by
intro c₁ c₂
show (c₁.2 ++ c₂.2).length ≤ c₁.2.length + c₂.2.length
rw [List.length_append]
exact Nat.le_refl _
/-- The three axis distinctions, descended to classes. -/
def axisD (t : Ax) : PhysicalState cont → Bool :=
Quotient.lift (fun a : Ax => decide (a = t)) (fun a b (h : cont a = cont b) => by rw [cont_inj a b h])
def D : Set (PhysicalState cont → Bool) := fun d => d = axisD zp ∨ d = axisD xp ∨ d = axisD yp
def dz : {d : PhysicalState cont → Bool // d ∈ D} := ⟨axisD zp, Or.inl rfl⟩
def dx : {d : PhysicalState cont → Bool // d ∈ D} := ⟨axisD xp, Or.inr (Or.inl rfl)⟩
def realignment : RealignmentModel cont D calib B :=
RealignmentModel.ofContinuation model D 0 Nat.zero_le hzero hP3
/-- (a₊, {d_z}) -/
def aPlus : Alignment cont D where
carrier := physicalClass cont zp
carried := fun d => d = dz
active := by intro d hd; have : d = dz := hd; subst this; decide
/-- (a₋, ∅) -/
def aMinus : Alignment cont D where
carrier := physicalClass cont zm
carried := fun _ => False
active := fun _ h => absurd h id
/-- (b₊, {d_x}) -/
def bPlus : Alignment cont D where
carrier := physicalClass cont xp
carried := fun d => d = dx
active := by intro d hd; have : d = dx := hd; subst this; decide
end ReachKernel.SpinControl
Source
APF ReachKernel; original archive f05a126714fe8d24a4377f87a7e460777555e19227087abb6c18dbe2ffae959e, ReachKernel/SpinControl.lean; corrected compatible source manifest 2c8ccc43b416ba6e4f1b9eb02d4780b828e8dab689651eb567f7d159065cdfd2. Private conditional/reference model.