2 ||M|| This file is part of HELM, an Hypertextual, Electronic
3 ||A|| Library of Mathematics, developed at the Computer Science
4 ||T|| Department of the University of Bologna, Italy.
8 \ / This file is distributed under the terms of the
9 \ / GNU General Public License Version 2
10 V_____________________________________________________________*)
17 include "turing/universal/marks.ma".
19 definition STape ≝ FinProd … FSUnialpha FinBool.
21 definition only_bits ≝ λl.
22 ∀c.memb STape c l = true → is_bit (\fst c) = true.
25 l0 x* a l1 x0* a0 l2 ------> l0 x a* l1 x0 a0* l2
28 if current (* x *) = #
33 if current (* x0 *) = 0
34 then advance_mark ----
38 else x = 1 (* analogo *)
44 MARK NEXT TUPLE machine
45 (partially axiomatized)
47 marks the first character after the first bar (rightwards)
50 definition bar_or_grid ≝ λc:STape.is_bar (\fst c) ∨ is_grid (\fst c).
52 definition mark_next_tuple ≝
53 seq ? (adv_to_mark_r ? bar_or_grid)
54 (ifTM ? (test_char ? (λc:STape.is_bar (\fst c)))
55 (move_right_and_mark ?) (nop ?) 1).
57 definition R_mark_next_tuple ≝
60 (* c non può essere un separatore ... speriamo *)
61 t1 = midtape ? ls c (rs1@〈grid,false〉::rs2) →
62 only_bits rs1 → bar_or_grid c = false →
63 (∃rs3,rs4,d,b.rs1 = rs3 @ 〈bar,false〉 :: rs4 ∧
64 Some ? 〈d,b〉 = option_hd ? (rs4@〈grid,false〉::rs2) ∧
65 t2 = midtape ? (bar::reverse ? rs3@c::ls) 〈d,true〉 (tail ? (rs4@〈grid,false〉::rs2)))
67 (memb ? bar rs1 = false ∧
68 t2 = midtape ? (reverse ? rs1@c::ls) 〈grid,false〉 rs2).
72 (∀x.memb A x l = true → f x = false) ∨
73 (∃l1,c,l2.f c = true ∧ l = l1@c::l2 ∧ ∀x.memb ? x l1 = true → f c = false).
75 [ % #x normalize #Hfalse *)
77 theorem sem_mark_next_tuple :
78 Realize ? mark_next_tuple R_mark_next_tuple.
80 lapply (sem_seq ? (adv_to_mark_r ? bar_or_grid)
81 (ifTM ? (test_char ? is_bar) (mark ?) (nop ?) 1) ????)
84 |||#Hif cases (Hif intape) -Hif
85 #j * #outc * #Hloop * #ta * #Hleft #Hright
86 @(ex_intro ?? j) @ex_intro [|% [@Hloop] ]
88 #ls #c #rs1 #rs2 #Hrs #Hrs1 #Hc
90 [ * #Hfalse >Hfalse in Hc; #Htf destruct (Htf)
91 | * #_ #Hta cases (tech_split ? is_bar rs1)
92 [ #H1 lapply (Hta rs1 grid rs2 (refl ??) ? ?)
93 [ (* Hrs1, H1 *) @daemon
94 | (* bar_or_grid grid = true *) @daemon
95 | -Hta #Hta cases Hright
96 [ * #tb * whd in ⊢ (%→?); #Hcurrent
97 @False_ind cases(Hcurrent grid ?)
98 [ #Hfalse (* grid is not a bar *) @daemon
100 | * #tb * whd in ⊢ (%→?); #Hcurrent
101 cases (Hcurrent grid ?)
102 [ #_ #Htb whd in ⊢ (%→?); #Houtc
105 | >Houtc >Htb >Hta % ]
109 | * #rs3 * #c0 * #rs4 * * #Hc0 #Hsplit #Hrs3
110 % @(ex_intro ?? rs3) @(ex_intro ?? rs4)
111 lapply (Hta rs3 c0 (rs4@grid::rs2) ???)
112 [ #x #Hrs3' (* Hrs1, Hrs3, Hsplit *) @daemon
113 | (* bar → bar_or_grid *) @daemon
114 | >Hsplit >associative_append % ] -Hta #Hta
116 [ * #tb * whd in ⊢ (%→?); #Hta'
119 [ #_ #Htb' >Htb' in Htb; #Htb
120 generalize in match Hsplit; -Hsplit
122 [ >(eq_pair_fst_snd … grid)
123 #Hta #Hsplit >(Htb … Hta)
125 [ @(ex_intro ?? (\fst grid)) @(ex_intro ?? (\snd grid))
126 % [ % [ % [ (* Hsplit *) @daemon |(*Hrs3*) @daemon ] | % ] | % ]
127 | (* Hc0 *) @daemon ]
128 | #r5 #rs5 >(eq_pair_fst_snd … r5)
129 #Hta #Hsplit >(Htb … Hta)
131 [ @(ex_intro ?? (\fst r5)) @(ex_intro ?? (\snd r5))
132 % [ % [ % [ (* Hc0, Hsplit *) @daemon | (*Hrs3*) @daemon ] | % ]
133 | % ] | (* Hc0 *) @daemon ] ] | >Hta % ]
134 | * #tb * whd in ⊢ (%→?); #Hta'
137 [ #Hfalse @False_ind >Hfalse in Hc0;