/machines/1RB0LC_0RC0RF_1RD0RE_1LE0RA_0LA0LE_1LD---/scripts/P124_model.v · raw
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 | (* Exact digit-level model of 1RB0LC_0RC0RF_1RD0RE_1LE0RA_0LA0LE_1LD--- (model lemmas only; no nonhalt). Derived from Sk1like_TC_v1.v (TM3 = 1RB0LC_0RC1RF_1RD0RE_1LE0RA_0LA0LE_1RD---). *) From BusyCoq Require Import Individual62. Require Import ZifyNat Lia. Require Import ZArith. Require Import String. Require Import List. Inductive RD := | D00101 | D0011 | D0011001 | D001101 | D00111 | D00001 | D001 | D01 | D0011_011001 | D001111001 | D00101001 | D0011_011 | D001111 | D00011 | D0011_01101 | D00111101 | D0010101 | D0011_0111 | D0011111 | D001011 | D0011_000101 | D0011_00101 | D0011_0101 | D0011101 | D0000101 . Inductive RT := | D001T . Inductive RC := | RC_S(x:RD)(n:N)(r:RC) | RC_O(x:RT). Definition toRD(x:RD) := match x with | D00101 => [0;0;1;0;1] | D0011 => [0;0;1;1] | D0011001 => [0;0;1;1;0;0;1] | D001101 => [0;0;1;1;0;1] | D00111 => [0;0;1;1;1] | D00001 => [0;0;0;0;1] | D001 => [0;0;1] | D01 => [0;1] | D0011_011001 => [0;0;1;1;0;1;1;0;0;1] | D001111001 => [0;0;1;1;1;1;0;0;1] | D00101001 => [0;0;1;0;1;0;0;1] | D0011_011 => [0;0;1;1;0;1;1] | D001111 => [0;0;1;1;1;1] | D00011 => [0;0;0;1;1] | D0011_01101 => [0;0;1;1;0;1;1;0;1] | D00111101 => [0;0;1;1;1;1;0;1] | D0010101 => [0;0;1;0;1;0;1] | D0011_0111 => [0;0;1;1;0;1;1;1] | D0011111 => [0;0;1;1;1;1;1] | D001011 => [0;0;1;0;1;1] | D0011_000101 => [0;0;1;1;0;0;0;1;0;1] | D0011_00101 => [0;0;1;1;0;0;1;0;1] | D0011_0101 => [0;0;1;1;0;1;0;1] | D0011101 => [0;0;1;1;1;0;1] | D0000101 => [0;0;0;0;1;0;1] end. Definition toRT(x:RT):side := match x with | D001T => [0;0;1] *> 0inf end. Notation w := [0;0;0;1]. Fixpoint toRC(x:RC):side := match x with | RC_S x0 n x1 => toRD x0 *> w^^N.to_nat n *> toRC x1 | RC_O x0 => toRT x0 end. Inductive Tp := | Tp0 | Tp1 | Tp2 | Tp3. Definition N_OS(a:N):= if (a=?0)%N then None else Some (N.pred a). Lemma N_OS_spec a: match N_OS a with | Some c => (a=1+c)%N | None => a = 0%N end. Proof. unfold N_OS. destruct (N.eqb_spec a 0); lia. Qed. Fixpoint RInc(x:RC)(dep:nat){struct dep}:RC*N*Tp+RC := (match dep with | O => inr x | S dep => match x with | RC_S a n r => match a with | D00101 => match N_OS n with | Some n => inl (RC_S D0011 n r,1,Tp0) | None => match r with | RC_S D00101 n0 r0 => match N_OS n0 with | Some n0 => inl (RC_S D0011001 n0 r0,1,Tp1) | None => inr x end | RC_S D0011001 n0 r0 => inl (RC_S D001 n0 r0,2,Tp0) | RC_S D001101 n0 r0 => inl (RC_S D01 n0 r0,2,Tp0) | RC_S D00111 n0 r0 => inl (RC_S D00011 n0 r0,1,Tp0) | _ => inr x end end | D0011 => match N_OS n with | Some n => inl (RC_S D0011001 n r,0,Tp0) | None => match r with | RC_S D01 n0 r0 => inl (RC_S D00111 n0 r0,0,Tp0) | RC_S D00101 n0 r0 => inl (RC_S D0011_0101 n0 r0,0,Tp0) | RC_S D0011 n0 r0 => inl (RC_S D0011_011 n0 r0,0,Tp0) | RC_S D0011001 n0 r0 => inl (RC_S D0011_011001 n0 r0,0,Tp0) | RC_S D001101 n0 r0 => inl (RC_S D0011_01101 n0 r0,0,Tp0) | RC_S D00111 n0 r0 => inl (RC_S D0011_0111 n0 r0,0,Tp0) | RC_S D0000101 n0 r0 => inl (RC_S D0011_000101 n0 r0,0,Tp0) | _ => inr x end end | D0011001 => inl (RC_S D001101 n r,0,Tp0) | D001101 => inl (RC_S D00111 n r,0,Tp0) | D00111 => match RInc r dep with | inl (r,dn,Tp0) => inl (RC_S D00101 (n+dn) r,0,Tp0) | inl (r,dn,Tp1) => inl (r,1+n+dn,Tp2) | inl (r,dn,Tp2) => match N_OS n with | Some n => inl (RC_S D00001 dn r,1+n,Tp2) | None => inr x end | inl (r,dn,Tp3) => match N_OS n with | Some n => inl (RC_S D0011001 dn r,1+n,Tp2) | None => inr x end | inr e => inr e end | D00001 => inl (RC_S D0011 n r,0,Tp0) | D001 => match N_OS n with | Some n => inl (RC_S D0011 n r,0,Tp1) | None => inr x end | D01 => match N_OS n with | Some n => inl (r,n,Tp3) | None => inr x end | D0011_011001 => inl (RC_S D001111001 n r,0,Tp0) | D001111001 => inl (RC_S D00101001 n r,0,Tp0) | D00101001 => match RInc r dep with | inl (r,dn,Tp0) => inl (r,2+n+dn,Tp0) | inr e => inr e | _ => inr x end | D0011_011 => inl (RC_S D001111 n r,0,Tp0) | D001111 => inl (RC_S D00101 n r,0,Tp0) | D00011 => inl (r,1+n,Tp0) | D0011_01101 => inl (RC_S D00111101 n r,0,Tp0) | D00111101 => inl (RC_S D0010101 n r,0,Tp0) | D0010101 => match N_OS n with | Some n => inl (RC_S D0011 n r,1,Tp1) | None => inr x end | D0011_0111 => inl (RC_S D0011111 n r,0,Tp0) | D0011111 => inl (RC_S D001011 n r,0,Tp0) | D001011 => match N_OS n with | Some n => inl (RC_S D0011001 n r,0,Tp1) | None => inr x end | D0011_000101 => inl (RC_S D0011_00101 n r,0,Tp0) | D0011_00101 => inl (RC_S D0011_0101 n r,0,Tp0) | D0011_0101 => inl (RC_S D0011101 n r,0,Tp0) | D0011101 => match N_OS n with | Some n => inl (RC_S D0011001 n r,0,Tp2) | None => inr x end | D0000101 => inl (RC_S D001101 n r,0,Tp0) end | RC_O a => match a with | D001T => inl (RC_O D001T,0,Tp1) end end end)%N. Definition maxD := 1000%nat. Definition Inc(x:N*RC):N*RC+RC := match x with | (n,r) => match RInc r maxD with | inl (r,dn,Tp0) => inl ((n+dn+1)%N,r) | inl (r,dn,Tp1) => inl (1%N,(RC_S D0011 (n+dn)%N r)) | inl (r,dn,Tp2) => match N_OS n with | Some n => inl (1%N,(RC_S D0011 n (RC_S D00001 dn r))) | None => inr r end | inl (r,dn,Tp3) => match N_OS n with | Some n => inl (1%N,(RC_S D0011 n (RC_S D0011001 dn r))) | None => inr r end | inr e => inr e end end. Module P124. Definition tm := Eval compute in (TM_from_str "1RB0LC_0RC0RF_1RD0RE_1LE0RA_0LA0LE_1LD---"). Notation "c -->* c'" := (c -[ tm ]->* c') (at level 40). Notation "c -->+ c'" := (c -[ tm ]->+ c') (at level 40). Definition toC(x:N*RC) := match x with | (n,r) => 0inf {{A}}> w^^N.to_nat n *> toRC r end. Ltac solve_N_OS := repeat match goal with | |- match match N_OS ?a with _ => _ end with _ => _ end => let I:=fresh "I" in epose proof (N_OS_spec a) as I; destruct (N_OS a); subst end. Ltac solve_v1 := trivial; intros; solve_N_OS; trivial; cbn[toRC]; cbn[toC]; repeat rewrite Nnat.N2Nat.inj_add; try solve[es]. Lemma RInc_spec x dep: match RInc x dep with | inl (x',n,Tp0) => forall l, l {{A}}> toRC x -->* l <{{C}} [0] *> w^^N.to_nat n *> toRC x' | inl (x',n,Tp1) => forall l, l {{A}}> toRC x -->* l <{{E}} [0;0;1] *> w^^N.to_nat n *> toRC x' | inl (x',n,Tp2) => forall l, l {{A}}> toRC x -->* l <{{E}} [0;0;0;1] *> w^^N.to_nat n *> toRC x' | inl (x',n,Tp3) => forall l, l {{A}}> toRC x -->* l <{{E}} [0;1;1;0;0;1] *> w^^N.to_nat n *> toRC x' | inr _ => True end. Proof. gen x. induction dep; cbn[RInc]; intros. 1: trivial. destruct x as [[] n x|[]]; solve_v1. - destruct x as [[] n x|[]]; solve_v1. - destruct x as [[] n x|[]]; solve_v1. - specialize (IHdep x). destruct (RInc x dep) as [[[r dn] []]|]; solve_v1. + es; er. follow IHdep. solve_v1. + es; er. follow IHdep. solve_v1. + es; er. follow IHdep. solve_v1. + es; er. follow IHdep. solve_v1. - specialize (IHdep x). destruct (RInc x dep) as [[[r dn] []]|]; solve_v1. + es; er. follow IHdep. solve_v1. Qed. Lemma Inc_spec x: match Inc x with | inl x' => toC x -->+ toC x' | _ => True end. Proof. destruct x as [n r]. unfold Inc. epose proof (RInc_spec r maxD). destruct (RInc r maxD) as [[[x' dn] []]|]; solve_v1. - es; er. follow H. solve_v1. - es; er. follow H. solve_v1. - es; er. follow H. solve_v1. - es; er. follow H. solve_v1. Qed. Definition x0:N*RC := (1,RC_S D0011 15 (RC_O D001T))%N. Lemma init: c0 -->* toC x0. Proof. esx. Qed. End P124. |