X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;ds=sidebyside;f=matita%2Fmatita%2Flib%2Fturing%2Fmulti_universal%2Fcompare.ma;h=8ad92d1e8b8f299e8908c63c36424cc3e397c24f;hb=a1dd5e64f21738a3f9ee1f635affeb9033e90954;hp=2a26abb3e73aa8d94c1d18d3131827e4d2cac19c;hpb=cdcfe9f97936f02dab1970ebf3911940bf0a4e29;p=helm.git diff --git a/matita/matita/lib/turing/multi_universal/compare.ma b/matita/matita/lib/turing/multi_universal/compare.ma index 2a26abb3e..8ad92d1e8 100644 --- a/matita/matita/lib/turing/multi_universal/compare.ma +++ b/matita/matita/lib/turing/multi_universal/compare.ma @@ -33,18 +33,18 @@ definition comp2 : compare_states ≝ mk_Sig ?? 2 (leb_true_to_le 3 3 (refl …) *) definition trans_compare_step ≝ - λi,j.λsig:FinSet.λn.λis_endc. + λi,j.λsig:FinSet.λn. λp:compare_states × (Vector (option sig) (S n)). let 〈q,a〉 ≝ p in match pi1 … q with [ O ⇒ match nth i ? a (None ?) with - [ None ⇒ 〈comp2,null_action ? n〉 + [ None ⇒ 〈comp2,null_action sig n〉 | Some ai ⇒ match nth j ? a (None ?) with [ None ⇒ 〈comp2,null_action ? n〉 - | Some aj ⇒ if notb (is_endc ai) ∧ ai == aj + | Some aj ⇒ if ai == aj then 〈comp1,change_vec ? (S n) - (change_vec ? (S n) (null_action ? n) (Some ? 〈ai,R〉) i) - (Some ? 〈aj,R〉) j〉 + (change_vec ? (S n) (null_action ? n) (〈None ?,R〉) i) + (〈None ?,R〉) j〉 else 〈comp2,null_action ? n〉 ] ] | S q ⇒ match q with @@ -52,284 +52,251 @@ definition trans_compare_step ≝ | S _ ⇒ (* 2 *) 〈comp2,null_action ? n〉 ] ]. definition compare_step ≝ - λi,j,sig,n,is_endc. - mk_mTM sig n compare_states (trans_compare_step i j sig n is_endc) + λi,j,sig,n. + mk_mTM sig n compare_states (trans_compare_step i j sig n) comp0 (λq.q == comp1 ∨ q == comp2). definition R_comp_step_true ≝ - λi,j,sig,n,is_endc.λint,outt: Vector (tape sig) (S n). + λi,j,sig,n.λint,outt: Vector (tape sig) (S n). ∃x. - is_endc x = false ∧ current ? (nth i ? int (niltape ?)) = Some ? x ∧ current ? (nth j ? int (niltape ?)) = Some ? x ∧ outt = change_vec ?? (change_vec ?? int - (tape_move ? (nth i ? int (niltape ?)) (Some ? 〈x,R〉)) i) - (tape_move ? (nth j ? int (niltape ?)) (Some ? 〈x,R〉)) j. + (tape_move_right ? (nth i ? int (niltape ?))) i) + (tape_move_right ? (nth j ? int (niltape ?))) j. definition R_comp_step_false ≝ - λi,j:nat.λsig,n,is_endc.λint,outt: Vector (tape sig) (S n). - ((∃x.current ? (nth i ? int (niltape ?)) = Some ? x ∧ is_endc x = true) ∨ - current ? (nth i ? int (niltape ?)) ≠ current ? (nth j ? int (niltape ?)) ∨ - current ? (nth i ? int (niltape ?)) = None ? ∨ - current ? (nth j ? int (niltape ?)) = None ?) ∧ outt = int. + λi,j:nat.λsig,n.λint,outt: Vector (tape sig) (S n). + (current ? (nth i ? int (niltape ?)) ≠ current ? (nth j ? int (niltape ?)) ∨ + current ? (nth i ? int (niltape ?)) = None ? ∨ + current ? (nth j ? int (niltape ?)) = None ?) ∧ outt = int. lemma comp_q0_q2_null : - ∀i,j,sig,n,is_endc,v.i < S n → j < S n → + ∀i,j,sig,n,v.i < S n → j < S n → (nth i ? (current_chars ?? v) (None ?) = None ? ∨ nth j ? (current_chars ?? v) (None ?) = None ?) → - step sig n (compare_step i j sig n is_endc) (mk_mconfig ??? comp0 v) + step sig n (compare_step i j sig n) (mk_mconfig ??? comp0 v) = mk_mconfig ??? comp2 v. -#i #j #sig #n #is_endc #v #Hi #Hj +#i #j #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 ] + | whd in ⊢ (??(????(???%))?); >Hcurrent @tape_move_null_action ] | @eq_f2 [ whd in ⊢ (??(???%)?); >Hcurrent cases (nth i ?? (None sig)) // - | whd in ⊢ (??(???????(???%))?); >Hcurrent + | whd in ⊢ (??(????(???%))?); >Hcurrent cases (nth i ?? (None sig)) [|#x] @tape_move_null_action ] ] qed. lemma comp_q0_q2_neq : - ∀i,j,sig,n,is_endc,v.i < S n → j < S n → - ((∃x.nth i ? (current_chars ?? v) (None ?) = Some ? x ∧ is_endc x = true) ∨ - nth i ? (current_chars ?? v) (None ?) ≠ nth j ? (current_chars ?? v) (None ?)) → - step sig n (compare_step i j sig n is_endc) (mk_mconfig ??? comp0 v) + ∀i,j,sig,n,v.i < S n → j < S n → + (nth i ? (current_chars ?? v) (None ?) ≠ nth j ? (current_chars ?? v) (None ?)) → + step sig n (compare_step i j sig n) (mk_mconfig ??? comp0 v) = mk_mconfig ??? comp2 v. -#i #j #sig #n #is_endc #v #Hi #Hj lapply (refl ? (nth i ?(current_chars ?? v)(None ?))) +#i #j #sig #n #v #Hi #Hj lapply (refl ? (nth i ?(current_chars ?? v)(None ?))) cases (nth i ?? (None ?)) in ⊢ (???%→?); [ #Hnth #_ @comp_q0_q2_null // % // | #ai #Hai lapply (refl ? (nth j ?(current_chars ?? v)(None ?))) cases (nth j ?? (None ?)) in ⊢ (???%→?); [ #Hnth #_ @comp_q0_q2_null // %2 // - | #aj #Haj * - [ * #c * >Hai #Heq #Hendc whd in ⊢ (??%?); - >(eq_pair_fst_snd … (trans ????)) whd in ⊢ (??%?); @eq_f2 - [ whd in match (trans ????); >Hai >Haj destruct (Heq) - whd in ⊢ (??(???%)?); >Hendc // - | whd in match (trans ????); >Hai >Haj destruct (Heq) - whd in ⊢ (??(???????(???%))?); >Hendc @tape_move_null_action - ] - | #Hneq - whd in ⊢ (??%?); >(eq_pair_fst_snd … (trans ????)) whd in ⊢ (??%?); @eq_f2 - [ whd in match (trans ????); >Hai >Haj - whd in ⊢ (??(???%)?); cut ((¬is_endc ai∧ai==aj)=false) - [>(\bf ?) /2 by not_to_not/ cases (is_endc ai) // |#Hcut >Hcut //] - | whd in match (trans ????); >Hai >Haj - whd in ⊢ (??(???????(???%))?); cut ((¬is_endc ai∧ai==aj)=false) - [>(\bf ?) /2 by not_to_not/ cases (is_endc ai) // - |#Hcut >Hcut @tape_move_null_action - ] - ] + | #aj #Haj * #Hneq + whd in ⊢ (??%?); >(eq_pair_fst_snd … (trans ????)) whd in ⊢ (??%?); @eq_f2 + [ whd in match (trans ????); >Hai >Haj + whd in ⊢ (??(???%)?); cut ((ai==aj)=false) + [>(\bf ?) /2 by not_to_not/ % #Haiaj @Hneq + >Hai >Haj // + | #Haiaj >Haiaj % ] + | whd in match (trans ????); >Hai >Haj + whd in ⊢ (??(????(???%))?); cut ((ai==aj)=false) + [>(\bf ?) /2 by not_to_not/ % #Haiaj @Hneq + >Hai >Haj // + |#Hcut >Hcut @tape_move_null_action ] ] + ] ] qed. lemma comp_q0_q1 : - ∀i,j,sig,n,is_endc,v,a.i ≠ j → i < S n → j < S n → - nth i ? (current_chars ?? v) (None ?) = Some ? a → is_endc a = false → + ∀i,j,sig,n,v,a.i ≠ j → i < S n → j < S n → + nth i ? (current_chars ?? v) (None ?) = Some ? a → nth j ? (current_chars ?? v) (None ?) = Some ? a → - step sig n (compare_step i j sig n is_endc) (mk_mconfig ??? comp0 v) = + step sig n (compare_step i j sig n) (mk_mconfig ??? comp0 v) = mk_mconfig ??? comp1 (change_vec ? (S n) (change_vec ?? v - (tape_move ? (nth i ? v (niltape ?)) (Some ? 〈a,R〉)) i) - (tape_move ? (nth j ? v (niltape ?)) (Some ? 〈a,R〉)) j). -#i #j #sig #n #is_endc #v #a #Heq #Hi #Hj #Ha1 #Hnotendc #Ha2 + (tape_move_right ? (nth i ? v (niltape ?))) i) + (tape_move_right ? (nth j ? v (niltape ?))) j). +#i #j #sig #n #v #a #Heq #Hi #Hj #Ha1 #Ha2 whd in ⊢ (??%?); >(eq_pair_fst_snd … (trans ????)) whd in ⊢ (??%?); @eq_f2 [ whd in match (trans ????); - >Ha1 >Ha2 whd in ⊢ (??(???%)?); >Hnotendc >(\b ?) // + >Ha1 >Ha2 whd in ⊢ (??(???%)?); >(\b ?) // | whd in match (trans ????); - >Ha1 >Ha2 whd in ⊢ (??(???????(???%))?); >Hnotendc >(\b ?) // - change with (change_vec ?????) in ⊢ (??(???????%)?); + >Ha1 >Ha2 whd in ⊢ (??(????(???%))?); >(\b ?) // + change with (change_vec ?????) in ⊢ (??(????%)?); <(change_vec_same … v j (niltape ?)) in ⊢ (??%?); <(change_vec_same … v i (niltape ?)) in ⊢ (??%?); - >pmap_change >pmap_change >tape_move_null_action - @eq_f2 // @eq_f2 // >nth_change_vec_neq // + >tape_move_multi_def + >pmap_change >pmap_change tape_move_null_action + @eq_f2 // >nth_change_vec_neq // ] qed. lemma sem_comp_step : - ∀i,j,sig,n,is_endc.i ≠ j → i < S n → j < S n → - compare_step i j sig n is_endc ⊨ - [ comp1: R_comp_step_true i j sig n is_endc, - R_comp_step_false i j sig n is_endc ]. -#i #j #sig #n #is_endc #Hneq #Hi #Hj #int + ∀i,j,sig,n.i ≠ j → i < S n → j < S n → + compare_step i j sig n ⊨ + [ comp1: R_comp_step_true i j sig n, + R_comp_step_false i j sig n ]. +#i #j #sig #n #Hneq #Hi #Hj #int lapply (refl ? (current ? (nth i ? int (niltape ?)))) cases (current ? (nth i ? int (niltape ?))) in ⊢ (???%→?); [ #Hcuri %{2} % [| % [ % - [ whd in ⊢ (??%?); >comp_q0_q2_null /2/ % comp_q0_q2_null /2/ | normalize in ⊢ (%→?); #H destruct (H) ] | #_ % // % %2 // ] ] | #a #Ha lapply (refl ? (current ? (nth j ? int (niltape ?)))) cases (current ? (nth j ? int (niltape ?))) in ⊢ (???%→?); [ #Hcurj %{2} % [| % [ % - [ whd in ⊢ (??%?); >comp_q0_q2_null /2/ %2 comp_q0_q2_null /2/ %2 | normalize in ⊢ (%→?); #H destruct (H) ] - | #_ % // >Ha >Hcurj % % %2 % #H destruct (H) ] ] - | #b #Hb %{2} - cases (true_or_false (is_endc a)) #Haendc + | #_ % // >Ha >Hcurj % % % #H destruct (H) ] ] + | #b #Hb %{2} cases (true_or_false (a == b)) #Hab [ % + [| % [ % + [whd in ⊢ (??%?); >(comp_q0_q1 … a Hneq Hi Hj) // + >(\P Hab) (\P Hab) %{b} % // % // <(\P Hab) // ] + | * #H @False_ind @H % + ] ] + | % [| % [ % [whd in ⊢ (??%?); >comp_q0_q2_neq // - % %{a} % // Ha >Hb + @(not_to_not ??? (\Pf Hab)) #H destruct (H) % | normalize in ⊢ (%→?); #H destruct (H) ] - | #_ % // % % % >Ha %{a} % // ] - ] - |cases (true_or_false (a == b)) #Hab - [ % - [| % [ % - [whd in ⊢ (??%?); >(comp_q0_q1 … a Hneq Hi Hj) // - [>(\P Hab) (\P Hab) %{b} % // % // <(\P Hab) % // ] - | * #H @False_ind @H % - ] ] - | % - [| % [ % - [whd in ⊢ (??%?); >comp_q0_q2_neq // - <(nth_vec_map ?? (current …) i ? int (niltape ?)) - <(nth_vec_map ?? (current …) j ? int (niltape ?)) %2 >Ha >Hb - @(not_to_not ??? (\Pf Hab)) #H destruct (H) % - | normalize in ⊢ (%→?); #H destruct (H) ] - | #_ % // % % %2 >Ha >Hb @(not_to_not ??? (\Pf Hab)) #H destruct (H) % ] ] - ] + | #_ % // % % >Ha >Hb @(not_to_not ??? (\Pf Hab)) #H destruct (H) % ] ] ] ] ] qed. -definition compare ≝ λi,j,sig,n,is_endc. - whileTM … (compare_step i j sig n is_endc) comp1. +definition compare ≝ λi,j,sig,n. + whileTM … (compare_step i j sig n) comp1. +(* (∃rs'.rs = rs0@rs' ∧ current ? (nth j ? outt (niltape ?)) = None ?) ∨ + (∃rs0'.rs0 = rs@rs0' ∧ + outt = change_vec ?? + (change_vec ?? int + (mk_tape sig (reverse sig rs@x::ls) (None sig) []) i) + (mk_tape sig (reverse sig rs@x::ls0) (option_hd sig rs0') + (tail sig rs0')) j) ∨ + (∃xs,ci,cj,rs',rs0'.ci ≠ cj ∧ rs = xs@ci::rs' ∧ rs0 = xs@cj::rs0' ∧ + outt = change_vec ?? + (change_vec ?? int (midtape sig (reverse ? xs@x::ls) ci rs') i) + (midtape sig (reverse ? xs@x::ls0) cj rs0') j)).*) definition R_compare ≝ - λi,j,sig,n,is_endc.λint,outt: Vector (tape sig) (S n). - ((∃x.current ? (nth i ? int (niltape ?)) = Some ? x ∧ is_endc x = true) ∨ - (current ? (nth i ? int (niltape ?)) ≠ current ? (nth j ? int (niltape ?)) ∨ + λi,j,sig,n.λint,outt: Vector (tape sig) (S n). + ((current ? (nth i ? int (niltape ?)) ≠ current ? (nth j ? int (niltape ?)) ∨ current ? (nth i ? int (niltape ?)) = None ? ∨ current ? (nth j ? int (niltape ?)) = None ?) → outt = int) ∧ - (∀ls,x,xs,ci,rs,ls0,rs0. - nth i ? int (niltape ?) = midtape sig ls x (xs@ci::rs) → - nth j ? int (niltape ?) = midtape sig ls0 x (xs@rs0) → - (∀c0. memb ? c0 (x::xs) = true → is_endc c0 = false) → - (rs0 = [ ] ∧ + (∀ls,x,rs,ls0,rs0. +(* nth i ? int (niltape ?) = midtape sig ls x (xs@ci::rs) → *) + nth i ? int (niltape ?) = midtape sig ls x rs → + nth j ? int (niltape ?) = midtape sig ls0 x rs0 → + (∃rs'.rs = rs0@rs' ∧ + outt = change_vec ?? + (change_vec ?? int + (mk_tape sig (reverse sig rs0@x::ls) (option_hd sig rs') (tail ? rs')) i) + (mk_tape sig (reverse sig rs0@x::ls0) (None ?) [ ]) j) ∨ + (∃rs0'.rs0 = rs@rs0' ∧ outt = change_vec ?? - (change_vec ?? int (midtape sig (reverse ? xs@x::ls) ci rs) i) - (mk_tape sig (reverse ? xs@x::ls0) (None ?) []) j) ∨ - ∃cj,rs1.rs0 = cj::rs1 ∧ - ((is_endc ci = true ∨ ci ≠ cj) → - outt = change_vec ?? - (change_vec ?? int (midtape sig (reverse ? xs@x::ls) ci rs) i) - (midtape sig (reverse ? xs@x::ls0) cj rs1) j)). + (change_vec ?? int + (mk_tape sig (reverse sig rs@x::ls) (None sig) []) i) + (mk_tape sig (reverse sig rs@x::ls0) (option_hd sig rs0') + (tail sig rs0')) j) ∨ + (∃xs,ci,cj,rs',rs0'.ci ≠ cj ∧ rs = xs@ci::rs' ∧ rs0 = xs@cj::rs0' ∧ + outt = change_vec ?? + (change_vec ?? int (midtape sig (reverse ? xs@x::ls) ci rs') i) + (midtape sig (reverse ? xs@x::ls0) cj rs0') j)). -lemma wsem_compare : ∀i,j,sig,n,is_endc.i ≠ j → i < S n → j < S n → - compare i j sig n is_endc ⊫ R_compare i j sig n is_endc. -#i #j #sig #n #is_endc #Hneq #Hi #Hj #ta #k #outc #Hloop -lapply (sem_while … (sem_comp_step i j sig n is_endc Hneq Hi Hj) … Hloop) // +lemma wsem_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 #ta #k #outc #Hloop +lapply (sem_while … (sem_comp_step i j sig n Hneq Hi Hj) … Hloop) // -Hloop * #tb * #Hstar @(star_ind_l ??????? Hstar) -Hstar -[ whd in ⊢ (%→?); * * [ * [ * - [* #curi * #Hcuri #Hendi #Houtc % - [ #_ @Houtc - | #ls #x #xs #ci #rs #ls0 #rs0 #Hnthi #Hnthj #Hnotendc - @False_ind - >Hnthi in Hcuri; normalize in ⊢ (%→?); #H destruct (H) - >(Hnotendc ? (memb_hd … )) in Hendi; #H destruct (H) - ] - |#Hcicj #Houtc % - [ #_ @Houtc - | #ls #x #xs #ci #rs #ls0 #rs0 #Hnthi #Hnthj - >Hnthi in Hcicj; >Hnthj normalize in ⊢ (%→?); * #H @False_ind @H % - ]] - | #Hci #Houtc % - [ #_ @Houtc - | #ls #x #xs #ci #rs #ls0 #rs0 #Hnthi >Hnthi in Hci; - normalize in ⊢ (%→?); #H destruct (H) ] ] - | #Hcj #Houtc % - [ #_ @Houtc - | #ls #x #xs #ci #rs #ls0 #rs0 #_ #Hnthj >Hnthj in Hcj; - normalize in ⊢ (%→?); #H destruct (H) ] ] - | #td #te * #x * * * #Hendcx #Hci #Hcj #Hd #Hstar #IH #He lapply (IH He) -IH * - #IH1 #IH2 % - [ >Hci >Hcj * [* #x0 * #H destruct (H) >Hendcx #H destruct (H) - |* [* #H @False_ind [cases H -H #H @H % | destruct (H)] | #H destruct (H)]] - | #ls #c0 #xs #ci #rs #ls0 #rs0 cases xs - [ #Hnthi #Hnthj #Hnotendc cases rs0 in Hnthj; - [ #Hnthj % % // >IH1 - [ >Hd @eq_f3 // - [ @eq_f3 // >(?:c0=x) [ >Hnthi % ] - >Hnthi in Hci;normalize #H destruct (H) % - | >(?:c0=x) [ >Hnthj % ] - >Hnthi in Hci;normalize #H destruct (H) % ] - | >Hd %2 %2 >nth_change_vec // >Hnthj % ] - | #r1 #rs1 #Hnthj %2 %{r1} %{rs1} % // * - [ #Hendci >IH1 - [ >Hd @eq_f3 // - [ @eq_f3 // >(?:c0=x) [ >Hnthi % ] - >Hnthi in Hci;normalize #H destruct (H) % - | >(?:c0=x) [ >Hnthj % ] - >Hnthi in Hci;normalize #H destruct (H) % ] - | >Hd >nth_change_vec // >nth_change_vec_neq [|@sym_not_eq //] - >nth_change_vec // >Hnthi >Hnthj normalize % %{ci} % // - ] - |#Hcir1 >IH1 - [>Hd @eq_f3 // - [ @eq_f3 // >(?:c0=x) [ >Hnthi % ] - >Hnthi in Hci;normalize #H destruct (H) % - | >(?:c0=x) [ >Hnthj % ] - >Hnthi in Hci;normalize #H destruct (H) % ] - | >Hd %2 % % >nth_change_vec // - >nth_change_vec_neq [|@sym_not_eq //] - >nth_change_vec // >Hnthi >Hnthj normalize @(not_to_not … Hcir1) - #H destruct (H) % ] - ] - ] - |#x0 #xs0 #Hnthi #Hnthj #Hnotendc - cut (c0 = x) [ >Hnthi in Hci; normalize #H destruct (H) // ] - #Hcut destruct (Hcut) cases rs0 in Hnthj; - [ #Hnthj % % // - cases (IH2 (x::ls) x0 xs0 ci rs (x::ls0) [ ] ???) -IH2 - [ * #_ #IH2 >IH2 >Hd >change_vec_commute in ⊢ (??%?); // - >change_vec_change_vec >change_vec_commute in ⊢ (??%?); // - @sym_not_eq // - | * #cj * #rs1 * #H destruct (H) - | >Hd >nth_change_vec_neq [|@sym_not_eq //] >nth_change_vec // - >Hnthi % - | >Hd >nth_change_vec // >Hnthj % - | #c0 #Hc0 @Hnotendc @memb_cons @Hc0 ] - | #r1 #rs1 #Hnthj %2 %{r1} %{rs1} % // #Hcir1 - cases(IH2 (x::ls) x0 xs0 ci rs (x::ls0) (r1::rs1) ???) - [ * #H destruct (H) - | * #r1' * #rs1' * #H destruct (H) #Hc1r1 >Hc1r1 // - >Hd >change_vec_commute in ⊢ (??%?); // - >change_vec_change_vec >change_vec_commute in ⊢ (??%?); // - @sym_not_eq // - | >Hd >nth_change_vec_neq [|@sym_not_eq //] >nth_change_vec // - >Hnthi // - | >Hd >nth_change_vec // >Hnthi >Hnthj % - | #c0 #Hc0 @Hnotendc @memb_cons @Hc0 -]]]]] -qed. +[ whd in ⊢ (%→?); * * [ * + [ #Hcicj #Houtc % + [ #_ @Houtc + | #ls #x #rs #ls0 #rs0 #Hnthi #Hnthj + >Hnthi in Hcicj; >Hnthj normalize in ⊢ (%→?); * #H @False_ind @H % + ] + | #Hci #Houtc % + [ #_ @Houtc + | #ls #x #rs #ls0 #rs0 #Hnthi >Hnthi in Hci; + normalize in ⊢ (%→?); #H destruct (H) ] ] + | #Hcj #Houtc % + [ #_ @Houtc + | #ls #x #rs #ls0 #rs0 #_ #Hnthj >Hnthj in Hcj; + normalize in ⊢ (%→?); #H destruct (H) ] ] +| #td #te * #x * * #Hci #Hcj #Hd #Hstar #IH #He lapply (IH He) -IH * + #IH1 #IH2 % + [ >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 // ] + >Hnthi >Hnthj % + | #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 >change_vec_commute // >change_vec_change_vec + >change_vec_commute // @sym_not_eq // ] + | * #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_compare : ∀i,j,sig,n,is_endc,t. +lemma terminate_compare : ∀i,j,sig,n,t. i ≠ j → i < S n → j < S n → - compare i j sig n is_endc ↓ t. -#i #j #sig #n #is_endc #t #Hneq #Hi #Hj + 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 +[ % #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 * * * #Hendcx >nth_change_vec // normalize in ⊢ (%→?); - #H1 destruct (H1) #Hxsep >change_vec_change_vec #Ht1 % - #t2 * #x0 * * * #Hendcx0 >Ht1 >nth_change_vec_neq [|@sym_not_eq //] + [#t #ls #c % #t1 * #x * * >nth_change_vec // normalize in ⊢ (%→?); + #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) #Hcur @@ -338,8 +305,9 @@ cases (nth i (tape sig) t (niltape ?)) ] qed. -lemma sem_compare : ∀i,j,sig,n,is_endc. +lemma sem_compare : ∀i,j,sig,n. i ≠ j → i < S n → j < S n → - compare i j sig n is_endc ⊨ R_compare i j sig n is_endc. -#i #j #sig #n #is_endc #Hneq #Hi #Hj @WRealize_to_Realize /2/ + 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.