From: Andrea Asperti Date: Tue, 15 Jan 2013 09:45:58 +0000 (+0000) Subject: copy.ma X-Git-Tag: make_still_working~1349 X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=commitdiff_plain;h=249addcfcf2681df796236b0f39a71260dddaa79;p=helm.git copy.ma --- diff --git a/matita/matita/lib/turing/multi_universal/copy.ma b/matita/matita/lib/turing/multi_universal/copy.ma index 284349ec5..18438c034 100644 --- a/matita/matita/lib/turing/multi_universal/copy.ma +++ b/matita/matita/lib/turing/multi_universal/copy.ma @@ -1,20 +1,18 @@ -(**************************************************************************) -(* ___ *) -(* ||M|| *) -(* ||A|| A project by Andrea Asperti *) -(* ||T|| *) -(* ||I|| Developers: *) -(* ||T|| The HELM team. *) -(* ||A|| http://helm.cs.unibo.it *) -(* \ / *) -(* \ / This file is distributed under the terms of the *) -(* v GNU General Public License Version 2 *) -(* *) -(**************************************************************************) +(* + ||M|| This file is part of HELM, an Hypertextual, Electronic + ||A|| Library of Mathematics, developed at the Computer Science + ||T|| Department of the University of Bologna, Italy. + ||I|| + ||T|| + ||A|| + \ / This file is distributed under the terms of the + \ / GNU General Public License Version 2 + V_____________________________________________________________*) -include "turing/turing.ma". +include "turing/multi_universal/moves.ma". +include "turing/if_multi.ma". include "turing/inject.ma". -include "turing/while_multi.ma". +include "turing/basic_machines.ma". definition copy_states ≝ initN 3. @@ -22,246 +20,243 @@ definition copy0 : copy_states ≝ mk_Sig ?? 0 (leb_true_to_le 1 3 (refl …)). definition copy1 : copy_states ≝ mk_Sig ?? 1 (leb_true_to_le 2 3 (refl …)). definition copy2 : copy_states ≝ mk_Sig ?? 2 (leb_true_to_le 3 3 (refl …)). -(* - -src: a b c ... z # ---→ a b c ... z # - ^ ^ - -dst: _ _ _ ... _ d ---→ a b c ... z d - ^ ^ - -0) (x ≠ sep,_) → (x,x)(R,R) → 1 - (sep,d) → None 2 -1) (_,_) → None 1 -2) (_,_) → None 2 - -*) definition trans_copy_step ≝ - λsrc,dst,sig,n,is_sep. + λsrc,dst.λsig:FinSet.λn. λp:copy_states × (Vector (option sig) (S n)). let 〈q,a〉 ≝ p in match pi1 … q with [ O ⇒ match nth src ? a (None ?) with - [ None ⇒ 〈copy2,null_action ? n〉 - | Some a0 ⇒ if is_sep a0 then 〈copy2,null_action ? n〉 - else 〈copy1,change_vec ? (S n) - (change_vec ?(S n) - (null_action ? n) (〈Some ? a0,R〉) src) - (〈Some ? a0,R〉) dst〉 ] + [ None ⇒ 〈copy2,null_action sig n〉 + | Some ai ⇒ match nth dst ? a (None ?) with + [ None ⇒ 〈copy2,null_action ? n〉 + | Some aj ⇒ + 〈copy1,change_vec ? (S n) + (change_vec ? (S n) (null_action ? n) (〈None ?,R〉) src) + (〈Some ? ai,R〉) dst〉 + ] + ] | S q ⇒ match q with [ O ⇒ (* 1 *) 〈copy1,null_action ? n〉 | S _ ⇒ (* 2 *) 〈copy2,null_action ? n〉 ] ]. definition copy_step ≝ - λsrc,dst,sig,n,is_sep. - mk_mTM sig n copy_states (trans_copy_step src dst sig n is_sep) + λsrc,dst,sig,n. + mk_mTM sig n copy_states (trans_copy_step src dst sig n) copy0 (λq.q == copy1 ∨ q == copy2). -definition R_copy_step_true ≝ - λsrc,dst,sig,n,is_sep.λint,outt: Vector (tape sig) (S n). - ∃x1. - current ? (nth src ? int (niltape ?)) = Some ? x1 ∧ - is_sep x1 = false ∧ +definition R_comp_step_true ≝ + λsrc,dst,sig,n.λint,outt: Vector (tape sig) (S n). + ∃x,y. + current ? (nth src ? int (niltape ?)) = Some ? x ∧ + current ? (nth dst ? int (niltape ?)) = Some ? y ∧ outt = change_vec ?? (change_vec ?? int - (tape_move_mono ? (nth src ? int (niltape ?)) (〈Some ? x1,R〉)) src) - (tape_move_mono ? (nth dst ? int (niltape ?)) (〈Some ? x1,R〉)) dst. + (tape_move_mono ? (nth src ? int (niltape ?)) 〈None ?, R〉) src) + (tape_move_mono ? (nth dst ? int (niltape ?)) 〈Some ? x, R〉) dst. -definition R_copy_step_false ≝ - λsrc,dst:nat.λsig,n,is_sep.λint,outt: Vector (tape sig) (S n). - (∃x1. - current ? (nth src ? int (niltape ?)) = Some ? x1 ∧ - is_sep x1 = true ∧ outt = int) ∨ - current ? (nth src ? int (niltape ?)) = None ? ∧ - outt = int. +definition R_comp_step_false ≝ + λsrc,dst:nat.λsig,n.λint,outt: Vector (tape sig) (S n). + (current ? (nth src ? int (niltape ?)) = None ? ∨ + current ? (nth dst ? int (niltape ?)) = None ?) ∧ outt = int. lemma copy_q0_q2_null : - ∀src,dst,sig,n,is_sep,v,t.src < S n → dst < S n → - current ? t = None ? → - step sig n (copy_step src dst sig n is_sep) - (mk_mconfig ??? copy0 (change_vec ? (S n) v t src)) = - mk_mconfig ??? copy2 (change_vec ? (S n) v t src). -#src #dst #sig #n #is_sep #v #t #Hsrc #Hdst #Hcurrent -whd in ⊢ (??%?); >(eq_pair_fst_snd … (trans ????)) whd in ⊢ (??%?); @eq_f2 -[ >current_chars_change_vec // whd in match (trans ????); - >nth_change_vec // >Hcurrent % -| >current_chars_change_vec // whd in match (trans ????); - >nth_change_vec // >Hcurrent @tape_move_null_action -] -qed. - -lemma copy_q0_q2_sep : - ∀src,dst,sig,n,is_sep,v,t.src < S n → dst < S n → - ∀s.current ? t = Some ? s → is_sep s = true → - step sig n (copy_step src dst sig n is_sep) - (mk_mconfig ??? copy0 (change_vec ? (S n) v t src)) = - mk_mconfig ??? copy2 (change_vec ? (S n) v t src). -#src #dst #sig #n #is_sep #v #t #Hsrc #Hdst #s #Hcurrent #Hsep -whd in ⊢ (??%?); >(eq_pair_fst_snd … (trans ????)) whd in ⊢ (??%?); @eq_f2 -[ >current_chars_change_vec // whd in match (trans ????); - >nth_change_vec // >Hcurrent whd in ⊢ (??(???%)?); >Hsep % -| >current_chars_change_vec // whd in match (trans ????); - >nth_change_vec // >Hcurrent whd in ⊢ (??(????(???%))?); - >Hsep @tape_move_null_action -] + ∀src,dst,sig,n,v.src < S n → dst < S n → + (nth src ? (current_chars ?? v) (None ?) = None ? ∨ + nth dst ? (current_chars ?? v) (None ?) = None ?) → + step sig n (copy_step src dst sig n) (mk_mconfig ??? copy0 v) + = mk_mconfig ??? copy2 v. +#src #dst #sig #n #v #Hi #Hj +whd in ⊢ (? → ??%?); >(eq_pair_fst_snd … (trans ????)) whd in ⊢ (?→??%?); +* #Hcurrent +[ @eq_f2 + [ whd in ⊢ (??(???%)?); >Hcurrent % + | whd in ⊢ (??(????(???%))?); >Hcurrent @tape_move_null_action ] +| @eq_f2 + [ whd in ⊢ (??(???%)?); >Hcurrent cases (nth src ?? (None sig)) // + | whd in ⊢ (??(????(???%))?); >Hcurrent + cases (nth src ?? (None sig)) [|#x] @tape_move_null_action ] ] qed. -axiom copy_q0_q1 : - ∀src,dst,sig,n,is_sep,v,t.src ≠ dst → src < S n → dst < S n → - ∀s.current ? t = Some ? s → is_sep s = false → - step sig n (copy_step src dst sig n is_sep) - (mk_mconfig ??? copy0 (change_vec ? (S n) v t src)) = +lemma copy_q0_q1 : + ∀src,dst,sig,n,v,a,b.src ≠ dst → src < S n → dst < S n → + nth src ? (current_chars ?? v) (None ?) = Some ? a → + nth dst ? (current_chars ?? v) (None ?) = Some ? b → + step sig n (copy_step src dst sig n) (mk_mconfig ??? copy0 v) = mk_mconfig ??? copy1 (change_vec ? (S n) (change_vec ?? v - (tape_move_mono ? t (〈Some ? s,R〉)) src) - (tape_move_mono ? (nth dst ? v (niltape ?)) (〈Some ? s,R〉)) dst). -(* -#src #dst #sig #n #is_sep #v #t #Hneq #Hsrc #Hdst #s #Hcurrent #Hsep + (tape_move_mono ? (nth src ? v (niltape ?)) 〈None ?, R〉) src) + (tape_move_mono ? (nth dst ? v (niltape ?)) 〈Some ? a, R〉) dst). +#src #dst #sig #n #v #a #b #Heq #Hsrc #Hdst #Ha1 #Ha2 whd in ⊢ (??%?); >(eq_pair_fst_snd … (trans ????)) whd in ⊢ (??%?); @eq_f2 -[ >current_chars_change_vec // whd in match (trans ????); - >nth_change_vec // >Hcurrent whd in ⊢ (??(???%)?); >Hsep % -| >current_chars_change_vec // whd in match (trans ????); - >nth_change_vec // >Hcurrent whd in ⊢ (??(????(???%))?); - >Hsep whd in ⊢ (??(????(???%))?); >change_vec_commute // >pmap_change - >change_vec_commute // @eq_f3 // - <(change_vec_same ?? v dst (niltape ?)) in ⊢(??%?); - >pmap_change @eq_f3 // +[ whd in match (trans ????); + >Ha1 >Ha2 whd in ⊢ (??(???%)?); >(\b ?) // +| whd in match (trans ????); + >Ha1 >Ha2 whd in ⊢ (??(????(???%))?); >(\b ?) // + change with (change_vec ?????) in ⊢ (??(????%)?); + <(change_vec_same … v dst (niltape ?)) in ⊢ (??%?); + <(change_vec_same … v src (niltape ?)) in ⊢ (??%?); + >tape_move_multi_def + >pmap_change >pmap_change tape_move_null_action + @eq_f2 // >nth_change_vec_neq // ] -qed.*) +qed. lemma sem_copy_step : - ∀src,dst,sig,n,is_sep.src ≠ dst → src < S n → dst < S n → - copy_step src dst sig n is_sep ⊨ - [ copy1: R_copy_step_true src dst sig n is_sep, - R_copy_step_false src dst sig n is_sep ]. -#src #dst #sig #n #is_sep #Hneq #Hsrc #Hdst #int + ∀src,dst,sig,n.src ≠ dst → src < S n → dst < S n → + copy_step src dst sig n ⊨ + [ copy1: R_comp_step_true src dst sig n, + R_comp_step_false src dst sig n ]. +#src #dst #sig #n #Hneq #Hsrc #Hdst #int lapply (refl ? (current ? (nth src ? int (niltape ?)))) cases (current ? (nth src ? int (niltape ?))) in ⊢ (???%→?); -[ #Hcur <(change_vec_same … int src (niltape ?)) %{2} % - [| % [ % +[ #Hcur_src %{2} % + [| % [ % [ whd in ⊢ (??%?); >copy_q0_q2_null /2/ | normalize in ⊢ (%→?); #H destruct (H) ] - | #_ %2 >nth_change_vec >Hcur // % // ] ] -| #c #Hcur cases (true_or_false (is_sep c)) #Hsep - [ <(change_vec_same … int src (niltape ?)) %{2} % + | #_ % // % // ] ] +| #a #Ha lapply (refl ? (current ? (nth dst ? int (niltape ?)))) + cases (current ? (nth dst ? int (niltape ?))) in ⊢ (???%→?); + [ #Hcur_dst %{2} % [| % [ % - [ whd in ⊢ (??%?); >copy_q0_q2_sep /2/ - | normalize in ⊢ (%→?); #H destruct (H) ] - | #_ % >nth_change_vec // %{c} % [ % /2/ | // ] ] ] - | %{2} % [| % [ % - [ whd in ⊢ (??%?); - <(change_vec_same … int src (niltape ?)) in ⊢ (??%?); - >Hcur in ⊢ (??%?); whd in ⊢ (??%?); >(copy_q0_q1 … Hsep) /2/ - | #_ whd %{c} % % /2/ ] - | * #Hfalse @False_ind /2/ ] ] ] ] + [ whd in ⊢ (??%?); >copy_q0_q2_null /2/ + | normalize in ⊢ (%→?); #H destruct (H) ] + | #_ % // %2 >Hcur_dst % ] ] + | #b #Hb %{2} % + [| % [ % + [whd in ⊢ (??%?); >(copy_q0_q1 … a b Hneq Hsrc Hdst) // + | #_ %{a} %{b} % // % //] + | * #H @False_ind @H % + ] + ] + ] +] qed. -definition copy ≝ λsrc,dst,sig,n,is_sep. - whileTM … (copy_step src dst sig n is_sep) copy1. +definition copy ≝ λsrc,dst,sig,n. + whileTM … (copy_step src dst sig n) copy1. definition R_copy ≝ - λsrc,dst,sig,n,is_sep.λint,outt: Vector (tape sig) (S n). - (∀ls,x,xs,rs,sep. - nth src ? int (niltape ?) = midtape sig ls x (xs@sep::rs) → - (∀c.memb ? c (x::xs) = true → is_sep c = false) → is_sep sep = true → - ∀ls0,x0,target,c,rs0.|xs| = |target| → - nth dst ? int (niltape ?) = midtape sig ls0 x0 (target@c::rs0) → - outt = change_vec ?? - (change_vec ?? int (midtape sig (reverse ? xs@x::ls) sep rs) src) - (midtape sig (reverse ? xs@x::ls0) c rs0) dst) ∧ - (∀c.current ? (nth src ? int (niltape ?)) = Some ? c → is_sep c = true → - outt = int) ∧ - (current ? (nth src ? int (niltape ?)) = None ? → outt = int). - -lemma wsem_copy : ∀src,dst,sig,n,is_sep.src ≠ dst → src < S n → dst < S n → - copy src dst sig n is_sep ⊫ R_copy src dst sig n is_sep. -#src #dst #sig #n #is_sep #Hneq #Hsrc #Hdst #ta #k #outc #Hloop -lapply (sem_while … (sem_copy_step src dst sig n is_sep Hneq Hsrc Hdst) … Hloop) // --Hloop * #tb * #Hstar @(star_ind_l ??????? Hstar) -Hstar -ta -[ whd in ⊢ (%→?); * - [ * #x * * #Hx #Hsep #Houtc % [ % - [ #ls #x0 #xs #rs #sep #Hsrctc #Hnosep >Hsrctc in Hx; normalize in ⊢ (%→?); - #Hx0 destruct (Hx0) lapply (Hnosep ? (memb_hd …)) >Hsep - #Hfalse destruct (Hfalse) - | #c #Hc #Hsepc @Houtc ] - | #_ @Houtc ] - | * #Hcur #Houtc % [ % - [ #ls #x0 #xs #rs #sep #Hsrctc >Hsrctc in Hcur; normalize in ⊢ (%→?); - #Hcur destruct (Hcur) - | #c #Hc #Hsepc @Houtc ] - | #_ @Houtc ] + λsrc,dst,sig,n.λint,outt: Vector (tape sig) (S n). + ((current ? (nth src ? int (niltape ?)) = None ? ∨ + current ? (nth dst ? int (niltape ?)) = None ?) → outt = int) ∧ + (∀ls,x,x0,rs,ls0,rs0. + nth src ? int (niltape ?) = midtape sig ls x rs → + nth dst ? int (niltape ?) = midtape sig ls0 x0 rs0 → + (∃rs01,rs02.rs0 = rs01@rs02 ∧ |rs01| = |rs| ∧ + outt = change_vec ?? + (change_vec ?? int + (mk_tape sig (reverse sig rs@x::ls) (None sig) []) src) + (mk_tape sig (reverse sig rs@x::ls0) (option_hd sig rs02) + (tail sig rs02)) dst) ∨ + (∃rs1,rs2.rs = rs1@rs2 ∧ |rs1| = |rs0| ∧ + outt = change_vec ?? + (change_vec ?? int + (mk_tape sig (reverse sig rs1@x::ls) (option_hd sig rs2) + (tail sig rs2)) src) + (mk_tape sig (reverse sig rs1@x::ls0) (None sig) []) dst)). + +axiom daemon : ∀P:Prop.P. + +lemma wsem_copy : ∀src,dst,sig,n.src ≠ dst → src < S n → dst < S n → + copy src dst sig n ⊫ R_copy src dst sig n. +#src #dst #sig #n #Hneq #Hsrc #Hdst #ta #k #outc #Hloop +lapply (sem_while … (sem_copy_step src dst sig n Hneq Hsrc Hdst) … Hloop) // +-Hloop * #tb * #Hstar @(star_ind_l ??????? Hstar) -Hstar +[ whd in ⊢ (%→?); * #Hnone #Hout % + [#_ @Hout + |#ls #x #x0 #rs #ls0 #rs0 #Hsrc1 #Hdst1 @False_ind cases Hnone + [>Hsrc1 normalize #H destruct (H) | >Hdst1 normalize #H destruct (H)] ] -| #td #te * #c0 * * #Hc0 #Hc0nosep #Hd #Hstar #IH #He - lapply (IH He) -IH * * #IH1 #IH2 #IH3 % [ % - [ #ls #x #xs #rs #sep #Hsrc_tc #Hnosep #Hsep #ls0 #x0 #target - #c #rs0 #Hlen #Hdst_tc - >Hsrc_tc in Hc0; normalize in ⊢ (%→?); #Hc0 destruct (Hc0) - <(change_vec_same … td src (niltape ?)) in Hd:(???(???(???%??)??)); - <(change_vec_same … td dst (niltape ?)) in ⊢(???(???(???%??)??)→?); - >Hdst_tc >Hsrc_tc >(change_vec_change_vec ?) >change_vec_change_vec - >(change_vec_commute ?? td ?? dst src) [|@(sym_not_eq … Hneq)] - >change_vec_change_vec @(list_cases2 … Hlen) - [ #Hxsnil #Htargetnil #Hd>(IH2 … Hsep) - [ >Hd -Hd >Hxsnil >Htargetnil @(eq_vec … (niltape ?)) - #i #Hi cases (decidable_eq_nat i src) #Hisrc - [ >Hisrc >(nth_change_vec_neq … src dst) [|@(sym_not_eq … Hneq)] - >nth_change_vec // >nth_change_vec // - >(nth_change_vec_neq … src dst) [|@(sym_not_eq … Hneq)] - >nth_change_vec // whd in ⊢ (??%?); % - | cases (decidable_eq_nat i dst) #Hidst - [ >Hidst >nth_change_vec // >nth_change_vec // - >nth_change_vec_neq // >Hdst_tc >Htargetnil % - | >nth_change_vec_neq [|@(sym_not_eq … Hidst)] - >nth_change_vec_neq [|@(sym_not_eq … Hisrc)] - >nth_change_vec_neq [|@(sym_not_eq … Hidst)] - >nth_change_vec_neq [|@(sym_not_eq … Hisrc)] % ] - ] - | >Hd >nth_change_vec_neq [|@(sym_not_eq … Hneq)] - >nth_change_vec // >nth_change_vec // >Hxsnil % ] - |#hd1 #hd2 #tl1 #tl2 #Hxs #Htarget >Hxs >Htarget #Hd - >(IH1 (c0::ls) hd1 tl1 rs sep ?? Hsep (c0::ls0) hd2 tl2 c rs0) - [ >Hd >(change_vec_commute … ?? td ?? src dst) // - >change_vec_change_vec - >(change_vec_commute … ?? td ?? dst src) [|@sym_not_eq //] - >change_vec_change_vec - >reverse_cons >associative_append >associative_append % - | >Hd >nth_change_vec // >nth_change_vec_neq // >Hdst_tc >Htarget // - | >Hxs in Hlen; >Htarget normalize #Hlen destruct (Hlen) // - | Hd >nth_change_vec_neq [|@sym_not_eq //] - >nth_change_vec // >nth_change_vec // ] - ] - | #c #Hc #Hsepc >Hc in Hc0; #Hcc0 destruct (Hcc0) >Hc0nosep in Hsepc; - #H destruct (H) - ] -| #HNone >HNone in Hc0; #Hc0 destruct (Hc0) ] ] +|#tc #td * #x * #y * * #Hcx #Hcy #Htd #Hstar #IH #He lapply (IH He) -IH * + #IH1 #IH2 % + [* [>Hcx #H destruct (H) | >Hcy #H destruct (H)] + |#ls #x' #y' #rs #ls0 #rs0 #Hnth_src #Hnth_dst + >Hnth_src in Hcx; whd in ⊢ (??%?→?); #H destruct (H) + >Hnth_dst in Hcy; whd in ⊢ (??%?→?); #H destruct (H) + >Hnth_src in Htd; >Hnth_dst -Hnth_src -Hnth_dst + cases rs + [(* the source tape is empty after the move *) + lapply (IH1 ?) [@daemon] + #Hout (* whd in match (tape_move ???); *) #Htemp %1 %{([])} %{rs0} % + [% [// | // ] + |whd in match (reverse ??); whd in match (reverse ??); + >Hout >Htemp @eq_f2 // cases rs0 // + ] + |#c1 #tl1 cases rs0 + [(* the dst tape is empty after the move *) + lapply (IH1 ?) [@daemon] + #Hout (* whd in match (tape_move ???); *) #Htemp %2 %{[ ]} %{(c1::tl1)} % + [% [// | // ] + |whd in match (reverse ??); whd in match (reverse ??); + >Hout >Htemp @eq_f2 // + ] + |#c2 #tl2 whd in match (tape_move_mono ???); whd in match (tape_move_mono ???); + #Htd + + + + [ >Hci >Hcj * [ * + [ * #H @False_ind @H % | #H destruct (H)] | #H destruct (H)] + | #ls #c0 #rs #ls0 #rs0 cases rs + [ -IH2 #Hnthi #Hnthj % %2 %{rs0} % [%] + >Hnthi in Hd; #Hd >Hd in IH1; #IH1 >IH1 + [| % %2 >nth_change_vec_neq [|@sym_not_eq //] >nth_change_vec // % ] + >Hnthj cases rs0 [| #r1 #rs1 ] % + | #r1 #rs1 #Hnthi cases rs0 + [ -IH2 #Hnthj % % %{(r1::rs1)} % [%] + >Hnthj in Hd; #Hd >Hd in IH1; #IH1 >IH1 + [| %2 >nth_change_vec // ] + >nth_change_vec // + | #r2 #rs2 #Hnthj lapply IH2; >Hd in IH1; >Hnthi >Hnthj + >nth_change_vec // + >nth_change_vec_neq [| @sym_not_eq // ] >nth_change_vec // + cases (true_or_false (r1 == r2)) #Hr1r2 + [ >(\P Hr1r2) #_ #IH2 cases (IH2 … (refl ??) (refl ??)) [ * + [ * #rs' * #Hrs1 #Hcurout_j % % %{rs'} + >Hrs1 >Hcurout_j normalize % // + | * #rs0' * #Hrs2 #Hcurout_i % %2 %{rs0'} + >Hrs2 >Hcurout_i % // + >change_vec_commute // >change_vec_change_vec + >change_vec_commute [|@sym_not_eq//] >change_vec_change_vec + >reverse_cons >associative_append >associative_append % ] + | * #xs * #ci * #cj * #rs' * #rs0' * * * #Hcicj #Hrs1 #Hrs2 + >change_vec_commute // >change_vec_change_vec + >change_vec_commute [| @sym_not_eq ] // >change_vec_change_vec + #Houtc %2 %{(r2::xs)} %{ci} %{cj} %{rs'} %{rs0'} + % [ % [ % [ // | >Hrs1 // ] | >Hrs2 // ] + | >reverse_cons >associative_append >associative_append >Houtc % ] ] + | lapply (\Pf Hr1r2) -Hr1r2 #Hr1r2 #IH1 #_ %2 + >IH1 [| % % normalize @(not_to_not … Hr1r2) #H destruct (H) % ] + %{[]} %{r1} %{r2} %{rs1} %{rs2} % [ % [ % /2/ | % ] | % ] ]]]]] qed. -lemma terminate_copy : ∀src,dst,sig,n,is_sep,t. - src ≠ dst → src < S n → dst < S n → - copy src dst sig n is_sep ↓ t. -#src #dst #sig #n #is_sep #t #Hneq #Hsrc #Hdst -@(terminate_while … (sem_copy_step …)) // -<(change_vec_same … t src (niltape ?)) -cases (nth src (tape sig) t (niltape ?)) -[ % #t1 * #x * * >nth_change_vec // normalize in ⊢ (%→?); #Hx destruct +lemma terminate_compare : ∀i,j,sig,n,t. + i ≠ j → i < S n → j < S n → + compare i j sig n ↓ t. +#i #j #sig #n #t #Hneq #Hi #Hj +@(terminate_while … (sem_comp_step …)) // +<(change_vec_same … t i (niltape ?)) +cases (nth i (tape sig) t (niltape ?)) +[ % #t1 * #x * * >nth_change_vec // normalize in ⊢ (%→?); #Hx destruct |2,3: #a0 #al0 % #t1 * #x * * >nth_change_vec // normalize in ⊢ (%→?); #Hx destruct | #ls #c #rs lapply c -c lapply ls -ls lapply t -t elim rs [#t #ls #c % #t1 * #x * * >nth_change_vec // normalize in ⊢ (%→?); - #H1 destruct (H1) #Hxsep >change_vec_change_vec #Ht1 % + #H1 destruct (H1) #_ >change_vec_change_vec #Ht1 % #t2 * #x0 * * >Ht1 >nth_change_vec_neq [|@sym_not_eq //] >nth_change_vec // normalize in ⊢ (%→?); #H destruct (H) |#r0 #rs0 #IH #t #ls #c % #t1 * #x * * >nth_change_vec // - normalize in ⊢ (%→?); #H destruct (H) #Hxsep + normalize in ⊢ (%→?); #H destruct (H) #Hcur >change_vec_change_vec >change_vec_commute // #Ht1 >Ht1 @IH ] ] qed. -lemma sem_copy : ∀src,dst,sig,n,is_sep. - src ≠ dst → src < S n → dst < S n → - copy src dst sig n is_sep ⊨ R_copy src dst sig n is_sep. -#src #dst #sig #n #is_sep #Hneq #Hsrc #Hdst @WRealize_to_Realize /2/ -qed. \ No newline at end of file +lemma sem_compare : ∀i,j,sig,n. + i ≠ j → i < S n → j < S n → + compare i j sig n ⊨ R_compare i j sig n. +#i #j #sig #n #Hneq #Hi #Hj @WRealize_to_Realize + [/2/| @wsem_compare // ] +qed.