From e94a85ba0e6313f88f0c1b6b9d28eb4c3294ba52 Mon Sep 17 00:00:00 2001 From: Andrea Asperti Date: Fri, 8 Jun 2012 10:49:53 +0000 Subject: [PATCH] A recompiling version --- matita/matita/lib/turing/universal/copy.ma | 14 +++++++--- .../matita/lib/turing/universal/move_tape.ma | 12 ++++---- .../matita/lib/turing/universal/uni_step.ma | 1 + .../matita/lib/turing/universal/universal.ma | 28 +++---------------- 4 files changed, 21 insertions(+), 34 deletions(-) diff --git a/matita/matita/lib/turing/universal/copy.ma b/matita/matita/lib/turing/universal/copy.ma index 331bf6881..5d8f4caab 100644 --- a/matita/matita/lib/turing/universal/copy.ma +++ b/matita/matita/lib/turing/universal/copy.ma @@ -10,7 +10,7 @@ V_____________________________________________________________*) -include "turing/universal/tuples.ma". +include "turing/universal/marks.ma". definition copy_step_subcase ≝ λalpha,c,elseM.ifTM ? (test_char ? (λx.x == 〈c,true〉)) @@ -68,7 +68,9 @@ cases (sem_if ? (test_char ? (λx. x == 〈c,true〉)) ?????? tc_true (sem_test_ #Hth whd in ⊢ (%→?); #Houtc cases (Houtc … Hth) -Houtc [ * >Hl1marks [ #Hfalse destruct (Hfalse) ] @memb_append_l2 @memb_hd ] * #_ #Houtc lapply (Houtc (reverse ? l1@[〈x,false〉]) 〈a,true〉 l3 ? (refl ??) ?) -Houtc - [ #x1 #Hx1 cases (memb_append … Hx1) -Hx1 #Hx1 [ @Hl1marks @memb_append_l1 @daemon | >(memb_single … Hx1) % ] + [ #x1 #Hx1 cases (memb_append … Hx1) -Hx1 #Hx1 + [@Hl1marks @memb_append_l1 <(reverse_reverse … l1) @memb_reverse @Hx1 + |>(memb_single … Hx1) % ] | normalize >associative_append % ] #Houtc lapply (\P Hx) -Hx #Hx destruct (Hx) % % [%] >Houtc >reverse_append >reverse_reverse >associative_append >associative_append % ] @@ -154,7 +156,9 @@ cases (sem_if ? (test_char ? (λx:STape.x == 〈null,true〉)) ?????? tc_true #Hth whd in ⊢ (%→?); #Houtc cases (Houtc … Hth) -Houtc [ * >Hl1marks [ #Hfalse destruct (Hfalse) ] @memb_append_l2 @memb_hd ] * #_ #Houtc lapply (Houtc (reverse ? l1@[〈x,false〉]) 〈a,true〉 l3 ? (refl ??) ?) -Houtc - [ #x1 #Hx1 cases (memb_append … Hx1) -Hx1 #Hx1 [ @Hl1marks @memb_append_l1 @daemon | >(memb_single … Hx1) % ] + [ #x1 #Hx1 cases (memb_append … Hx1) -Hx1 #Hx1 + [@Hl1marks @memb_append_l1 <(reverse_reverse … l1) @memb_reverse @Hx1 + |>(memb_single … Hx1) % ] | normalize >associative_append % ] #Houtc lapply (\P Hx) -Hx #Hx destruct (Hx) % % [%] >Houtc >reverse_append >reverse_reverse >associative_append >associative_append % ] @@ -272,6 +276,8 @@ lemma inj_append_singleton_l2 : >reverse_append >reverse_append normalize #H1 destruct % qed. +axiom daemon : ∀P:Prop.P. + lemma wsem_copy0 : WRealize ? copy0 R_copy0. #intape #k #outc #Hloop lapply (sem_while … sem_copy_step intape k outc Hloop) [%] -Hloop @@ -292,7 +298,7 @@ lapply (sem_while … sem_copy_step intape k outc Hloop) [%] -Hloop #Hl1 #Hl1bits #l4' #bg #Hl4 #Hl4bits %2 cases (Htc … Htb) -Htc #Hcbitnull #Htc % [ % #Hc' >Hc' in Hcbitnull; normalize #Hfalse destruct (Hfalse) ] - cut (|l1| = |reverse ? l4|) [@daemon] #Hlen1 + cut (|l1| = |reverse ? l4|) [>length_reverse @Hlen] #Hlen1 @(list_cases2 … Hlen1) [ (* case l1 = [] is discriminated because l1 contains at least comma *) #Hl1nil @False_ind >Hl1nil in Hl1; cases l1' normalize diff --git a/matita/matita/lib/turing/universal/move_tape.ma b/matita/matita/lib/turing/universal/move_tape.ma index 9ad227dbe..ecc9fa208 100644 --- a/matita/matita/lib/turing/universal/move_tape.ma +++ b/matita/matita/lib/turing/universal/move_tape.ma @@ -9,8 +9,8 @@ \ / GNU General Public License Version 2 V_____________________________________________________________*) -include "turing/universal/move_char_c.ma". -include "turing/universal/move_char_l.ma". +include "turing/move_char.ma". +include "turing/universal/marks.ma". include "turing/universal/tuples.ma". definition init_cell_states ≝ initN 2. @@ -197,7 +197,7 @@ MOVE TAPE LEFT: *) definition mtl_aux ≝ seq ? (swap STape 〈grid,false〉) - (seq ? (move_r …) (seq ? (move_r …) (seq ? (move_char_c STape 〈grid,false〉) (move_l …)))). + (seq ? (move_r …) (seq ? (move_r …) (seq ? (move_char_r STape 〈grid,false〉) (move_l …)))). definition R_mtl_aux ≝ λt1,t2. ∀l1,l2,l3,r. t1 = midtape STape l1 r (〈grid,false〉::l2@〈grid,false〉::l3) → no_grids l2 → t2 = midtape STape (reverse ? l2@〈grid,false〉::l1) r (〈grid,false〉::l3). @@ -205,7 +205,7 @@ definition R_mtl_aux ≝ λt1,t2. lemma sem_mtl_aux : Realize ? mtl_aux R_mtl_aux. #intape cases (sem_seq … (sem_swap STape 〈grid,false〉) (sem_seq … (sem_move_r …) - (sem_seq … (sem_move_r …) (sem_seq … (ssem_move_char_c STape 〈grid,false〉) + (sem_seq … (sem_move_r …) (sem_seq … (ssem_move_char_r STape 〈grid,false〉) (sem_move_l …)))) intape) #k * #outc * #Hloop #HR @(ex_intro ?? k) @(ex_intro ?? outc) % [@Hloop] -Hloop #l1 #l2 #l3 #r #Hintape #Hl2 @@ -340,14 +340,14 @@ cases HR -HR #ta * whd in ⊢ (%→?); #Hta lapply (Hta … Htapein) qed. (*definition mtl_aux ≝ - seq ? (move_r …) (seq ? (move_char_c STape 〈grid,false〉) (move_l …)). + seq ? (move_r …) (seq ? (move_char_r STape 〈grid,false〉) (move_l …)). definition R_mtl_aux ≝ λt1,t2. ∀l1,l2,l3,r. t1 = midtape STape l1 r (l2@〈grid,false〉::l3) → no_grids l2 → t2 = midtape STape (reverse ? l2@l1) r (〈grid,false〉::l3). lemma sem_mtl_aux : Realize ? mtl_aux R_mtl_aux. #intape -cases (sem_seq … (sem_move_r …) (sem_seq … (ssem_move_char_c STape 〈grid,false〉) (sem_move_l …)) intape) +cases (sem_seq … (sem_move_r …) (sem_seq … (ssem_move_char_r STape 〈grid,false〉) (sem_move_l …)) intape) #k * #outc * #Hloop #HR @(ex_intro ?? k) @(ex_intro ?? outc) % [@Hloop] -Hloop #l1 #l2 #l3 #r #Hintape #Hl2 cases HR -HR #ta * whd in ⊢ (%→?); #Hta lapply (Hta … Hintape) -Hta #Hta diff --git a/matita/matita/lib/turing/universal/uni_step.ma b/matita/matita/lib/turing/universal/uni_step.ma index b28efc472..395decac2 100644 --- a/matita/matita/lib/turing/universal/uni_step.ma +++ b/matita/matita/lib/turing/universal/uni_step.ma @@ -16,6 +16,7 @@ include "turing/universal/copy.ma". include "turing/universal/move_tape.ma". +include "turing/universal/match_machines.ma". (* diff --git a/matita/matita/lib/turing/universal/universal.ma b/matita/matita/lib/turing/universal/universal.ma index 5ffbc8d4e..3350b0965 100644 --- a/matita/matita/lib/turing/universal/universal.ma +++ b/matita/matita/lib/turing/universal/universal.ma @@ -10,30 +10,10 @@ V_____________________________________________________________*) -include "turing/universal/trans_to_tuples.ma". include "turing/universal/uni_step.ma". (* definition zero : ∀n.initN n ≝ λn.mk_Sig ?? 0 (le_O_n n). *) -record normalTM : Type[0] ≝ -{ no_states : nat; - pos_no_states : (0 < no_states); - ntrans : trans_source no_states → trans_target no_states; - nhalt : initN no_states → bool -}. - -definition normalTM_to_TM ≝ λM:normalTM. - mk_TM FinBool (initN (no_states M)) - (ntrans M) (mk_Sig ?? 0 (pos_no_states M)) (nhalt M). - -coercion normalTM_to_TM. - -definition nconfig ≝ λn. config FinBool (initN n). - -(* -definition normalTM ≝ λn,t,h. - λk:0