From: Ferruccio Guidi Date: Thu, 27 Apr 2017 18:20:12 +0000 (+0000) Subject: refactoring ... X-Git-Tag: make_still_working~453 X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=commitdiff_plain;h=a961853f4bb6f26c4cc8ca9babad0de0e6c6d1ff;p=helm.git refactoring ... --- diff --git a/matita/matita/contribs/lambdadelta/basic_2/syntax/aarity.ma b/matita/matita/contribs/lambdadelta/basic_2/syntax/aarity.ma index 165410d41..4db5d3115 100644 --- a/matita/matita/contribs/lambdadelta/basic_2/syntax/aarity.ma +++ b/matita/matita/contribs/lambdadelta/basic_2/syntax/aarity.ma @@ -16,7 +16,7 @@ * Initial invocation: - Patience on me to gain peace and perfection! - *) -include "ground_2/lib/star.ma". +include "ground_2/lib/relations.ma". include "basic_2/notation/constructors/item0_0.ma". include "basic_2/notation/constructors/snitem2_2.ma". diff --git a/matita/matita/contribs/lambdadelta/ground_2/lib/arith.ma b/matita/matita/contribs/lambdadelta/ground_2/lib/arith.ma index 2c6ad2a56..9a3f0810f 100644 --- a/matita/matita/contribs/lambdadelta/ground_2/lib/arith.ma +++ b/matita/matita/contribs/lambdadelta/ground_2/lib/arith.ma @@ -15,7 +15,7 @@ include "ground_2/notation/functions/successor_1.ma". include "ground_2/notation/functions/predecessor_1.ma". include "arithmetics/nat.ma". -include "ground_2/lib/star.ma". +include "ground_2/lib/relations.ma". (* ARITHMETICAL PROPERTIES **************************************************) diff --git a/matita/matita/contribs/lambdadelta/ground_2/lib/bool.ma b/matita/matita/contribs/lambdadelta/ground_2/lib/bool.ma index 1a91e6ec4..01f2780ff 100644 --- a/matita/matita/contribs/lambdadelta/ground_2/lib/bool.ma +++ b/matita/matita/contribs/lambdadelta/ground_2/lib/bool.ma @@ -13,7 +13,7 @@ (**************************************************************************) include "basics/bool.ma". -include "ground_2/lib/star.ma". +include "ground_2/lib/relations.ma". include "ground_2/notation/constructors/no_0.ma". include "ground_2/notation/constructors/yes_0.ma". diff --git a/matita/matita/contribs/lambdadelta/ground_2/lib/relations.ma b/matita/matita/contribs/lambdadelta/ground_2/lib/relations.ma new file mode 100644 index 000000000..3f5c3b409 --- /dev/null +++ b/matita/matita/contribs/lambdadelta/ground_2/lib/relations.ma @@ -0,0 +1,96 @@ +(**************************************************************************) +(* ___ *) +(* ||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 *) +(* *) +(**************************************************************************) + +include "basics/relations.ma". +include "ground_2/xoa/xoa_props.ma". + +(* GENERIC RELATIONS ********************************************************) + +(* PROPERTIES OF RELATIONS **************************************************) + +definition relation5 : Type[0] → Type[0] → Type[0] → Type[0] → Type[0] → Type[0] +≝ λA,B,C,D,E.A→B→C→D→E→Prop. + +definition relation6 : Type[0] → Type[0] → Type[0] → Type[0] → Type[0] → Type[0] → Type[0] +≝ λA,B,C,D,E,F.A→B→C→D→E→F→Prop. + +definition Decidable: Prop → Prop ≝ λR. R ∨ (R → ⊥). + +definition Transitive: ∀A. ∀R: relation A. Prop ≝ λA,R. + ∀a1,a0. R a1 a0 → ∀a2. R a0 a2 → R a1 a2. + +definition left_cancellable: ∀A. ∀R: relation A. Prop ≝ λA,R. + ∀a0,a1. R a0 a1 → ∀a2. R a0 a2 → R a1 a2. + +definition right_cancellable: ∀A. ∀R: relation A. Prop ≝ λA,R. + ∀a1,a0. R a1 a0 → ∀a2. R a2 a0 → R a1 a2. + +definition pw_confluent2: ∀A. relation A → relation A → predicate A ≝ λA,R1,R2,a0. + ∀a1. R1 a0 a1 → ∀a2. R2 a0 a2 → + ∃∃a. R2 a1 a & R1 a2 a. + +definition confluent2: ∀A. relation (relation A) ≝ λA,R1,R2. + ∀a0. pw_confluent2 A R1 R2 a0. + +definition transitive2: ∀A. ∀R1,R2: relation A. Prop ≝ λA,R1,R2. + ∀a1,a0. R1 a1 a0 → ∀a2. R2 a0 a2 → + ∃∃a. R2 a1 a & R1 a a2. + +definition bi_confluent: ∀A,B. ∀R: bi_relation A B. Prop ≝ λA,B,R. + ∀a0,a1,b0,b1. R a0 b0 a1 b1 → ∀a2,b2. R a0 b0 a2 b2 → + ∃∃a,b. R a1 b1 a b & R a2 b2 a b. + +definition lsub_trans: ∀A,B. relation2 (A→relation B) (relation A) ≝ λA,B,R1,R2. + ∀L2,T1,T2. R1 L2 T1 T2 → ∀L1. R2 L1 L2 → R1 L1 T1 T2. + +definition s_r_confluent1: ∀A,B. relation2 (A→relation B) (B→relation A) ≝ λA,B,R1,R2. + ∀L1,T1,T2. R1 L1 T1 T2 → ∀L2. R2 T1 L1 L2 → R2 T2 L1 L2. + +definition is_mono: ∀B:Type[0]. predicate (predicate B) ≝ + λB,R. ∀b1. R b1 → ∀b2. R b2 → b1 = b2. + +definition is_inj2: ∀A,B:Type[0]. predicate (relation2 A B) ≝ + λA,B,R. ∀a1,b. R a1 b → ∀a2. R a2 b → a1 = a2. + +(* Normal form and strong normalization *************************************) + +definition NF: ∀A. relation A → relation A → predicate A ≝ + λA,R,S,a1. ∀a2. R a1 a2 → S a1 a2. + +definition NF_dec: ∀A. relation A → relation A → Prop ≝ + λA,R,S. ∀a1. NF A R S a1 ∨ + ∃∃a2. R … a1 a2 & (S a1 a2 → ⊥). + +inductive SN (A) (R,S:relation A): predicate A ≝ +| SN_intro: ∀a1. (∀a2. R a1 a2 → (S a1 a2 → ⊥) → SN A R S a2) → SN A R S a1 +. + +lemma NF_to_SN: ∀A,R,S,a. NF A R S a → SN A R S a. +#A #R #S #a1 #Ha1 +@SN_intro #a2 #HRa12 #HSa12 +elim HSa12 -HSa12 /2 width=1 by/ +qed. + +definition NF_sn: ∀A. relation A → relation A → predicate A ≝ + λA,R,S,a2. ∀a1. R a1 a2 → S a1 a2. + +inductive SN_sn (A) (R,S:relation A): predicate A ≝ +| SN_sn_intro: ∀a2. (∀a1. R a1 a2 → (S a1 a2 → ⊥) → SN_sn A R S a1) → SN_sn A R S a2 +. + +lemma NF_to_SN_sn: ∀A,R,S,a. NF_sn A R S a → SN_sn A R S a. +#A #R #S #a2 #Ha2 +@SN_sn_intro #a1 #HRa12 #HSa12 +elim HSa12 -HSa12 /2 width=1 by/ +qed. diff --git a/matita/matita/contribs/lambdadelta/ground_2/lib/star.ma b/matita/matita/contribs/lambdadelta/ground_2/lib/star.ma index 26832eb42..fdf2ae5a4 100644 --- a/matita/matita/contribs/lambdadelta/ground_2/lib/star.ma +++ b/matita/matita/contribs/lambdadelta/ground_2/lib/star.ma @@ -13,57 +13,19 @@ (**************************************************************************) include "basics/star1.ma". -include "ground_2/xoa/xoa_props.ma". +include "ground_2/lib/relations.ma". -(* PROPERTIES OF RELATIONS **************************************************) - -definition relation5 : Type[0] → Type[0] → Type[0] → Type[0] → Type[0] → Type[0] -≝ λA,B,C,D,E.A→B→C→D→E→Prop. - -definition relation6 : Type[0] → Type[0] → Type[0] → Type[0] → Type[0] → Type[0] → Type[0] -≝ λA,B,C,D,E,F.A→B→C→D→E→F→Prop. - -definition Decidable: Prop → Prop ≝ λR. R ∨ (R → ⊥). - -definition Transitive: ∀A. ∀R: relation A. Prop ≝ λA,R. - ∀a1,a0. R a1 a0 → ∀a2. R a0 a2 → R a1 a2. - -definition left_cancellable: ∀A. ∀R: relation A. Prop ≝ λA,R. - ∀a0,a1. R a0 a1 → ∀a2. R a0 a2 → R a1 a2. - -definition right_cancellable: ∀A. ∀R: relation A. Prop ≝ λA,R. - ∀a1,a0. R a1 a0 → ∀a2. R a2 a0 → R a1 a2. - -definition pw_confluent2: ∀A. relation A → relation A → predicate A ≝ λA,R1,R2,a0. - ∀a1. R1 a0 a1 → ∀a2. R2 a0 a2 → - ∃∃a. R2 a1 a & R1 a2 a. - -definition confluent2: ∀A. relation (relation A) ≝ λA,R1,R2. - ∀a0. pw_confluent2 A R1 R2 a0. - -definition transitive2: ∀A. ∀R1,R2: relation A. Prop ≝ λA,R1,R2. - ∀a1,a0. R1 a1 a0 → ∀a2. R2 a0 a2 → - ∃∃a. R2 a1 a & R1 a a2. - -definition bi_confluent: ∀A,B. ∀R: bi_relation A B. Prop ≝ λA,B,R. - ∀a0,a1,b0,b1. R a0 b0 a1 b1 → ∀a2,b2. R a0 b0 a2 b2 → - ∃∃a,b. R a1 b1 a b & R a2 b2 a b. +(* TRANSITIVE CLOSURE *******************************************************) definition LTC: ∀A:Type[0]. ∀B. (A→relation B) → (A→relation B) ≝ λA,B,R,a. TC … (R a). -definition lsub_trans: ∀A,B. relation2 (A→relation B) (relation A) ≝ λA,B,R1,R2. - ∀L2,T1,T2. R1 L2 T1 T2 → ∀L1. R2 L1 L2 → R1 L1 T1 T2. - definition s_r_transitive: ∀A,B. relation2 (A→relation B) (B→relation A) ≝ λA,B,R1,R2. ∀L2,T1,T2. R1 L2 T1 T2 → ∀L1. R2 T1 L1 L2 → LTC … R1 L1 T1 T2. definition s_rs_transitive: ∀A,B. relation2 (A→relation B) (B→relation A) ≝ λA,B,R1,R2. ∀L2,T1,T2. LTC … R1 L2 T1 T2 → ∀L1. R2 T1 L1 L2 → LTC … R1 L1 T1 T2. -definition s_r_confluent1: ∀A,B. relation2 (A→relation B) (B→relation A) ≝ λA,B,R1,R2. - ∀L1,T1,T2. R1 L1 T1 T2 → ∀L2. R2 T1 L1 L2 → R2 T2 L1 L2. - lemma TC_strip1: ∀A,R1,R2. confluent2 A R1 R2 → ∀a0,a1. TC … R1 a0 a1 → ∀a2. R2 a0 a2 → ∃∃a. R2 a1 a & TC … R1 a2 a. @@ -134,44 +96,6 @@ lemma TC_transitive2: ∀A,R1,R2. ] qed. -definition NF: ∀A. relation A → relation A → predicate A ≝ - λA,R,S,a1. ∀a2. R a1 a2 → S a1 a2. - -definition NF_dec: ∀A. relation A → relation A → Prop ≝ - λA,R,S. ∀a1. NF A R S a1 ∨ - ∃∃a2. R … a1 a2 & (S a1 a2 → ⊥). - -inductive SN (A) (R,S:relation A): predicate A ≝ -| SN_intro: ∀a1. (∀a2. R a1 a2 → (S a1 a2 → ⊥) → SN A R S a2) → SN A R S a1 -. - -lemma NF_to_SN: ∀A,R,S,a. NF A R S a → SN A R S a. -#A #R #S #a1 #Ha1 -@SN_intro #a2 #HRa12 #HSa12 -elim HSa12 -HSa12 /2 width=1 by/ -qed. - -lemma SN_to_NF: ∀A,R,S. NF_dec A R S → - ∀a1. SN A R S a1 → - ∃∃a2. star … R a1 a2 & NF A R S a2. -#A #R #S #HRS #a1 #H elim H -a1 -#a1 #_ #IHa1 elim (HRS a1) -HRS /2 width=3 by srefl, ex2_intro/ -* #a0 #Ha10 #Ha01 elim (IHa1 … Ha10 Ha01) -IHa1 -Ha01 /3 width=3 by star_compl, ex2_intro/ -qed-. - -definition NF_sn: ∀A. relation A → relation A → predicate A ≝ - λA,R,S,a2. ∀a1. R a1 a2 → S a1 a2. - -inductive SN_sn (A) (R,S:relation A): predicate A ≝ -| SN_sn_intro: ∀a2. (∀a1. R a1 a2 → (S a1 a2 → ⊥) → SN_sn A R S a1) → SN_sn A R S a2 -. - -lemma NF_to_SN_sn: ∀A,R,S,a. NF_sn A R S a → SN_sn A R S a. -#A #R #S #a2 #Ha2 -@SN_sn_intro #a1 #HRa12 #HSa12 -elim HSa12 -HSa12 /2 width=1 by/ -qed. - lemma LTC_lsub_trans: ∀A,B,R,S. lsub_trans A B R S → lsub_trans A B (LTC … R) S. #A #B #R #S #HRS #L2 #T1 #T2 #H elim H -T2 /3 width=3 by inj/ #T #T2 #_ #HT2 #IHT1 #L1 #HL12 @@ -215,7 +139,17 @@ elim (TC_idem … (S L2) … T1 T2) #_ #H1 #H2 #_ @H2 @HSR /3 width=3 by/ qed-. -(* relations on unboxed pairs ***********************************************) +(* Normal form and strong normalization *************************************) + +lemma SN_to_NF: ∀A,R,S. NF_dec A R S → + ∀a1. SN A R S a1 → + ∃∃a2. star … R a1 a2 & NF A R S a2. +#A #R #S #HRS #a1 #H elim H -a1 +#a1 #_ #IHa1 elim (HRS a1) -HRS /2 width=3 by srefl, ex2_intro/ +* #a0 #Ha10 #Ha01 elim (IHa1 … Ha10 Ha01) -IHa1 -Ha01 /3 width=3 by star_compl, ex2_intro/ +qed-. + +(* Relations on unboxed pairs ***********************************************) lemma bi_TC_strip: ∀A,B,R. bi_confluent A B R → ∀a0,a1,b0,b1. R a0 b0 a1 b1 → ∀a2,b2. bi_TC … R a0 b0 a2 b2 → @@ -256,7 +190,7 @@ lemma bi_TC_decomp_l: ∀A,B. ∀R:bi_relation A B. ] qed-. -(* relations on unboxed triples *********************************************) +(* Relations on unboxed triples *********************************************) definition tri_RC: ∀A,B,C. tri_relation A B C → tri_relation A B C ≝ λA,B,C,R,a1,b1,c1,a2,b2,c2. R … a1 b1 c1 a2 b2 c2 ∨ diff --git a/matita/matita/contribs/lambdadelta/ground_2/lib/streams.ma b/matita/matita/contribs/lambdadelta/ground_2/lib/streams.ma index d342a9934..4ae6c939a 100644 --- a/matita/matita/contribs/lambdadelta/ground_2/lib/streams.ma +++ b/matita/matita/contribs/lambdadelta/ground_2/lib/streams.ma @@ -13,7 +13,7 @@ (**************************************************************************) include "ground_2/notation/constructors/cons_2.ma". -include "ground_2/lib/star.ma". +include "ground_2/lib/relations.ma". (* STREAMS ******************************************************************) diff --git a/matita/matita/contribs/lambdadelta/ground_2/web/ground_2_src.tbl b/matita/matita/contribs/lambdadelta/ground_2/web/ground_2_src.tbl index a5d4181ed..4cfc0f6eb 100644 --- a/matita/matita/contribs/lambdadelta/ground_2/web/ground_2_src.tbl +++ b/matita/matita/contribs/lambdadelta/ground_2/web/ground_2_src.tbl @@ -48,7 +48,7 @@ table { [ "stream ( ? @ ? )" "stream_eq ( ? ≐ ? )" "stream_hdtl ( ↓? )" "stream_tls ( ↓*[?]? )" * ] [ "list ( ◊ ) ( ? @ ? ) ( |?| )" "list2 ( ◊ ) ( {?,?} @ ? ) ( ? @@ ? ) ( |?| )" * ] [ "bool ( Ⓕ ) ( Ⓣ )" "arith ( ?^? ) ( ⫯? ) ( ⫰? ) ( ? ∨ ? ) ( ? ∧ ? )" * ] - [ "star" "lstar" * ] + [ "relations" "star" "lstar" * ] } ] }