Skip to content

Commit 912afa5

Browse files
committed
Prove cubic-finned meithecatte#3
Also modify existing proofs to avoid using a single variable in two exponents. Their being necessary was an artifact of a shortcoming of a previous version of the `finned` tactic – and in the current proof, it is necessary to avoid them instead. Modify all the other proofs for consistency.
1 parent f93915a commit 912afa5

File tree

5 files changed

+103
-28
lines changed

5 files changed

+103
-28
lines changed

verify/Finned.v

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
From BusyCoq Require Import Individual52.
2-
From Coq Require Import Lia.
2+
From Coq Require Import Lia PeanoNat.
3+
4+
Ltac deduce_eq0 :=
5+
lazymatch goal with
6+
| H: _ + _ = O |- _ =>
7+
apply Nat.eq_add_0 in H; destruct H
8+
| H: S _ * _ = O |- _ =>
9+
apply Nat.eq_mul_0_r in H; [| discriminate]
10+
| H: ?x = O |- _ =>
11+
is_var x; subst x
12+
end.
313

414
Ltac single := eapply progress_intro; [prove_step | simpl_tape].
5-
Ltac goto x := match type of x with
15+
Ltac goto x := lazymatch type of x with
616
| I => exists x
717
| _ -> I => exists (x ltac:(lia))
818
end; single; finish.
@@ -95,7 +105,7 @@ Ltac maybe_casesplit_at xs :=
95105
lazymatch xs with
96106
| _^^?n *> _ =>
97107
let n' := fresh n "'" in
98-
destruct n as [| n']; try lia
108+
destruct n as [| n']; try lia; repeat deduce_eq0
99109
| _ => idtac
100110
end.
101111

verify/Finned3.v

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
(** * Cubic-finned machine #3 (https://bbchallenge.org/10756090) *)
2+
3+
From BusyCoq Require Import Individual52 Finned.
4+
Set Default Goal Selector "!".
5+
6+
(* NOTE: this swaps L and R compared to the TNF form *)
7+
Definition tm : TM := fun '(q, s) =>
8+
match q, s with
9+
| A, 0 => Some (1, L, B) | A, 1 => Some (1, L, E)
10+
| B, 0 => Some (1, R, C) | B, 1 => Some (1, L, B)
11+
| C, 0 => Some (0, L, A) | C, 1 => Some (0, R, D)
12+
| D, 0 => Some (1, R, B) | D, 1 => Some (1, R, D)
13+
| E, 0 => None | E, 1 => Some (0, L, A)
14+
end.
15+
16+
Notation "c --> c'" := (c -[ tm ]-> c') (at level 40).
17+
Notation "c -->* c'" := (c -[ tm ]->* c') (at level 40).
18+
Notation "c -->+ c'" := (c -[ tm ]->+ c') (at level 40).
19+
20+
Close Scope sym.
21+
22+
Inductive I : Type :=
23+
| I0 (a b : nat) (H : 2*a = b + 1) : I
24+
| I1 (a b : nat) (H : 2*a = b) : I
25+
| I2 (a b d : nat) (H : 2*a = b + 2*d + 1) : I
26+
| I3 (a b d : nat) (H : 2*a = b + 2*d + 2) : I
27+
| I4 (a d : nat) (H : a = d) : I
28+
| I5 (a b c d : nat) (H : 2*a + d = b + c) : I
29+
| I6 (a c d : nat) (H : 2*a + d = c) : I
30+
| I7 (a c d : nat) (H : 2*a + d = c) : I
31+
| I8 (a b c d : nat) (H : 2*a + d = b + c + 3) : I
32+
| I9 (a b d : nat) (H : 2*a + d = b + 2) : I
33+
.
34+
35+
Open Scope sym.
36+
37+
Definition f (i : I) : Q * tape :=
38+
match i with
39+
| I0 a b _ => B;;
40+
const 0 <* [1]^^a << 0 <* [1]^^b {{0}} const 0
41+
| I1 a b _ => C;;
42+
const 0 <* [1]^^a << 0 <* [1]^^b {{0}} const 0
43+
| I2 a b d _ => A;;
44+
const 0 <* [1]^^a << 0 <* [1]^^b {{1}} [0; 1]^^d *> const 0
45+
| I3 a b d _ => E;;
46+
const 0 <* [1]^^a << 0 <* [1]^^b {{1}} 1 >> [0; 1]^^d *> const 0
47+
| I4 a d _ => A;;
48+
const 0 <* [1]^^a {{0}} [0; 1]^^d *> const 0
49+
| I5 a b c d _ => B;;
50+
const 0 <* [1]^^a << 0 <* [1]^^b {{1}} [1]^^c *> [0; 1]^^d *> const 0
51+
| I6 a c d _ => B;;
52+
const 0 <* [1]^^a {{0}} 1 >> [1]^^c *> [0; 1]^^d *> const 0
53+
| I7 a c d _ => C;;
54+
const 0 <* [1]^^a << 1 {{1}} [1]^^c *> [0; 1]^^d *> const 0
55+
| I8 a b c d _ => D;;
56+
const 0 <* [1]^^a << 0 <* [1]^^b {{1}} [1]^^c *> [0; 1]^^d *> const 0
57+
| I9 a b d _ => D;;
58+
const 0 <* [1]^^a << 0 <* [1]^^b {{0}} [1; 0]^^d *> const 0
59+
end.
60+
61+
Theorem nonhalt : ~ halts tm c0.
62+
Proof.
63+
apply progress_nonhalt_simple with (C := f) (i0 := I4 0 0 eq_refl).
64+
intros []; finned.
65+
Qed.

verify/Finned4.v

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@ Notation "c -->+ c'" := (c -[ tm ]->+ c') (at level 40).
1919
Close Scope sym.
2020

2121
Inductive I : Type :=
22-
| I0 (a b : nat) (H : 2*a = b) : I (* 1RB -> I1 *)
23-
| I1 (a b : nat) (H : 2*a + 1 = b) : I (* 0LC -> I2 *)
24-
| I2 (a b d : nat) (H : 2*a = b + 2*d) : I (* 1LD -> I3, I4 *)
25-
| I3 (a b d : nat) (H : 2*a = b + 2*d + 1) : I (* 0LC -> I2 *)
26-
| I4 (a : nat) : I (* 1RA -> I0, I5 *)
27-
| I5 (a b c d : nat) (H : 2*a + d + 1 = b + c) : I (* 1LA -> I5, I6 *)
28-
| I6 (a c d : nat) (H : 2*a + d + 1 = c) : I (* 1RB -> I7 *)
29-
| I7 (a c d : nat) (H : 2*a + d + 1 = c) : I (* 0RE -> I8 *)
30-
| I8 (a b c d : nat) (H : 2*a + d = b + c + 2) : I (* 1RE -> I8, I9 *)
31-
| I9 (a b d : nat) (H : 2*a + d = b + 1) : I (* 1RA -> I5 *)
22+
| I0 (a b : nat) (H : 2*a = b) : I
23+
| I1 (a b : nat) (H : 2*a + 1 = b) : I
24+
| I2 (a b d : nat) (H : 2*a = b + 2*d) : I
25+
| I3 (a b d : nat) (H : 2*a = b + 2*d + 1) : I
26+
| I4 (a d : nat) (H : a = d) : I
27+
| I5 (a b c d : nat) (H : 2*a + d + 1 = b + c) : I
28+
| I6 (a c d : nat) (H : 2*a + d + 1 = c) : I
29+
| I7 (a c d : nat) (H : 2*a + d + 1 = c) : I
30+
| I8 (a b c d : nat) (H : 2*a + d = b + c + 2) : I
31+
| I9 (a b d : nat) (H : 2*a + d = b + 1) : I
3232
.
3333

3434
Open Scope sym.
@@ -43,8 +43,8 @@ Definition f (i : I) : Q * tape :=
4343
const 0 <* [1]^^a << 0 <* [1]^^b {{1}} [0; 1]^^d *> const 0
4444
| I3 a b d _ => D;;
4545
const 0 <* [1]^^a << 0 <* [1]^^b {{1}} 1 >> [0; 1]^^d *> const 0
46-
| I4 a => D;;
47-
const 0 <* [1]^^a {{0}} 1 >> [0; 1]^^a *> const 0
46+
| I4 a d _ => D;;
47+
const 0 <* [1]^^a {{0}} 1 >> [0; 1]^^d *> const 0
4848
| I5 a b c d _ => A;;
4949
const 0 <* [1]^^a << 0 <* [1]^^b {{1}} [1]^^c *> [0; 1]^^d *> const 0
5050
| I6 a c d _ => A;;

verify/Finned5.v

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@ Notation "c -->+ c'" := (c -[ tm ]->+ c') (at level 40).
1919
Close Scope sym.
2020

2121
Inductive I : Type :=
22-
| I0 (a b : nat) (H : 2*a = b) : I (* 1RB -> I1 *)
23-
| I1 (a b : nat) (H : 2*a + 1 = b) : I (* 0LC -> I2 *)
24-
| I2 (a b d : nat) (H : 2*a = b + 2*d) : I (* 1LD -> I3, I4 *)
25-
| I3 (a b d : nat) (H : 2*a = b + 2*d + 1) : I (* 0LC -> I2 *)
26-
| I4 (a : nat) : I (* 1LA -> I5, I6 *)
27-
| I5 (a b c d : nat) (H : 2*a + d + 1 = b + c) : I (* 1LA -> I5, I6 *)
28-
| I6 (a c d : nat) (H : 2*a + d + 1 = c) : I (* 1RB -> I7 *)
29-
| I7 (a c d : nat) (H : 2*a + d + 1 = c) : I (* 0RE -> I8 *)
30-
| I8 (a b c d : nat) (H : 2*a + d = b + c + 2) : I (* 1RE -> I8, I9 *)
31-
| I9 (a b d : nat) (H : 2*a + d = b + 1) : I (* 1RA -> I0, I5 *)
22+
| I0 (a b : nat) (H : 2*a = b) : I
23+
| I1 (a b : nat) (H : 2*a + 1 = b) : I
24+
| I2 (a b d : nat) (H : 2*a = b + 2*d) : I
25+
| I3 (a b d : nat) (H : 2*a = b + 2*d + 1) : I
26+
| I4 (a d : nat) (H : a = d) : I
27+
| I5 (a b c d : nat) (H : 2*a + d + 1 = b + c) : I
28+
| I6 (a c d : nat) (H : 2*a + d + 1 = c) : I
29+
| I7 (a c d : nat) (H : 2*a + d + 1 = c) : I
30+
| I8 (a b c d : nat) (H : 2*a + d = b + c + 2) : I
31+
| I9 (a b d : nat) (H : 2*a + d = b + 1) : I
3232
.
3333

3434
Open Scope sym.
@@ -43,8 +43,8 @@ Definition f (i : I) : Q * tape :=
4343
const 0 <* [1]^^a << 0 <* [1]^^b {{1}} [0; 1]^^d *> const 0
4444
| I3 a b d _ => D;;
4545
const 0 <* [1]^^a << 0 <* [1]^^b {{1}} 1 >> [0; 1]^^d *> const 0
46-
| I4 a => D;;
47-
const 0 <* [1]^^a {{0}} 1 >> [0; 1]^^a *> const 0
46+
| I4 a d _ => D;;
47+
const 0 <* [1]^^a {{0}} 1 >> [0; 1]^^d *> const 0
4848
| I5 a b c d _ => A;;
4949
const 0 <* [1]^^a << 0 <* [1]^^b {{1}} [1]^^c *> [0; 1]^^d *> const 0
5050
| I6 a c d _ => A;;

verify/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ COQMFFLAGS := -Q . BusyCoq
33
ALLVFILES := LibTactics.v Helper.v Pigeonhole.v TM.v Compute.v Flip.v Permute.v DirectedCompute.v Subtape.v \
44
Cyclers.v TranslatedCyclers.v BackwardsReasoning.v Bouncers.v Individual.v \
55
BB52.v Individual52.v FixedBin.v ShiftOverflow.v ShiftOverflowBins.v Skelet15.v Skelet26.v Skelet33.v Skelet34.v Skelet35.v \
6-
Skelet10.v Skelet17.v Skelet1.v Finned.v Finned1.v Finned2.v Finned4.v Finned5.v Extraction.v \
6+
Skelet10.v Skelet17.v Skelet1.v Finned.v Finned1.v Finned2.v Finned3.v Finned4.v Finned5.v Extraction.v \
77
BB33.v Individual33.v
88

99
all: check verify skelet1

0 commit comments

Comments
 (0)