From: matitaweb Date: Tue, 8 Nov 2011 16:54:31 +0000 (+0000) Subject: commit by user andrea X-Git-Tag: make_still_working~2128 X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=commitdiff_plain;h=5f6f12fa3806e9bfe4fa79a5555912b68dcd0f00;p=helm.git commit by user andrea --- diff --git a/weblib/tutorial/chapter4.ma b/weblib/tutorial/chapter4.ma index 9bfb3891c..79b6bafff 100644 --- a/weblib/tutorial/chapter4.ma +++ b/weblib/tutorial/chapter4.ma @@ -45,7 +45,7 @@ interpretation "atom" 'atom a = (char ? a). notation "ϵ" non associative with precedence 90 for @{ 'epsilon }. interpretation "epsilon" 'epsilon = (epsilon ?). -notation "∅" non associative with precedence 90 for @{ 'empty }. +notation "∅" (* slash emptyv *) non associative with precedence 90 for @{ 'empty }. interpretation "empty" 'empty = (zero ?). let rec flatten (S : a href="cic:/matita/tutorial/chapter4/Alpha.ind(1,0,0)"Alpha/a) (l : a href="cic:/matita/tutorial/chapter3/list.ind(1,0,1)"list/a (a href="cic:/matita/tutorial/chapter4/word.def(3)"word/a S)) on l : a href="cic:/matita/tutorial/chapter4/word.def(3)"word/a S ≝ @@ -67,76 +67,75 @@ interpretation "union lang" 'union a b = (union ? a b). definition cat : ∀S,l1,l2,w.Prop ≝ λS.λl1,l2.λw:a href="cic:/matita/tutorial/chapter4/word.def(3)"word/a S.a title="exists" href="cic:/fakeuri.def(1)"∃/aw1,w2.w1 a title="append" href="cic:/fakeuri.def(1)"@/a w2 a title="leibnitz's equality" href="cic:/fakeuri.def(1)"=/a w a title="logical and" href="cic:/fakeuri.def(1)"∧/a l1 w1 a title="logical and" href="cic:/fakeuri.def(1)"∧/a l2 w2. -interpretation "cat lang" 'pc a b = (cat ? a b). +interpretation "cat lang" 'concat a b = (cat ? a b). definition star ≝ λS.λl.λw:a href="cic:/matita/tutorial/chapter4/word.def(3)"word/a S.a title="exists" href="cic:/fakeuri.def(1)"∃/alw. a href="cic:/matita/tutorial/chapter4/flatten.fix(0,1,4)"flatten/a ? lw a title="leibnitz's equality" href="cic:/fakeuri.def(1)"=/a w a title="logical and" href="cic:/fakeuri.def(1)"∧/a a href="cic:/matita/tutorial/chapter4/conjunct.fix(0,1,4)"conjunct/a ? lw l. interpretation "star lang" 'kstar l = (star ? l). -notation > "𝐋 term 70 E" non associative with precedence 75 for @{in_l ? $E}. +notation "ℓ term 70 E" non associative with precedence 75 for @{in_l ? $E}. let rec in_l (S : a href="cic:/matita/tutorial/chapter4/Alpha.ind(1,0,0)"Alpha/a) (r : a href="cic:/matita/tutorial/chapter4/re.ind(1,0,1)"re/a S) on r : a href="cic:/matita/tutorial/chapter4/word.def(3)"word/a S → Prop ≝ match r with - [ zero ⇒ a title="empty lang" href="cic:/fakeuri.def(1)"∅/a + [ zero ⇒ a title="empty lang" href="cic:/fakeuri.def(1)"∅/a | epsilon ⇒ a title="sing lang" href="cic:/fakeuri.def(1)"{/a: a title="nil" href="cic:/fakeuri.def(1)"[/a] } - | char x ⇒ a title="sing lang" href="cic:/fakeuri.def(1)"{/a: a title="cons" href="cic:/fakeuri.def(1)"[/ax]span style="text-decoration: underline;"/span} - | _ ⇒ a title="empty lang" href="cic:/fakeuri.def(1)"∅/a + | char x ⇒ a title="sing lang" href="cic:/fakeuri.def(1)"{/a: xa title="cons" href="cic:/fakeuri.def(1)":/a:a title="nil" href="cic:/fakeuri.def(1)"[/a] } + | concat r1 r2 ⇒ ℓ r1 a title="cat lang" href="cic:/fakeuri.def(1)"·/a ℓ r2 + | or r1 r2 ⇒ ℓ r1 a title="union lang" href="cic:/fakeuri.def(1)"∪/a ℓ r2 + | star r1 ⇒ (ℓ r1)a title="star lang" href="cic:/fakeuri.def(1)"^/a* ]. - -(* - | concat r1 r2 ⇒ 𝐋 r1 · 𝐋 r2 - | or r1 r2 ⇒ 𝐋 r1 ∪ 𝐋 r2 - | star r1 ⇒ (𝐋 r1) ^* - ]. - -*) - - notation "𝐋 term 70 E" non associative with precedence 75 for @{'in_l $E}. +notation "ℓ term 70 E" non associative with precedence 75 for @{'in_l $E}. interpretation "in_l" 'in_l E = (in_l ? E). interpretation "in_l mem" 'mem w l = (in_l ? l w). -notation "a || b" left associative with precedence 30 for @{'orb $a $b}. +notation "a ∨ b" left associative with precedence 30 for @{'orb $a $b}. interpretation "orb" 'orb a b = (orb a b). -ndefinition if_then_else ≝ λT:Type[0].λe,t,f.match e return λ_.T with [ true ⇒ t | false ⇒ f]. +(* ndefinition if_then_else ≝ λT:Type[0].λe,t,f.match e return λ_.T with [ true ⇒ t | false ⇒ f]. notation > "'if' term 19 e 'then' term 19 t 'else' term 19 f" non associative with precedence 19 for @{ 'if_then_else $e $t $f }. notation < "'if' \nbsp term 19 e \nbsp 'then' \nbsp term 19 t \nbsp 'else' \nbsp term 90 f \nbsp" non associative with precedence 19 for @{ 'if_then_else $e $t $f }. -interpretation "if_then_else" 'if_then_else e t f = (if_then_else ? e t f). - -ninductive pitem (S: Alpha) : Type[0] ≝ - pz: pitem S - | pe: pitem S - | ps: S → pitem S - | pp: S → pitem S - | pc: pitem S → pitem S → pitem S - | po: pitem S → pitem S → pitem S - | pk: pitem S → pitem S. +interpretation "if_then_else" 'if_then_else e t f = (if_then_else ? e t f). *) + +inductive pitem (S: a href="cic:/matita/tutorial/chapter4/Alpha.ind(1,0,0)"Alpha/a) : Type[0] ≝ + | pzero: pitem S + | pepsilon: pitem S + | pchar: S → pitem S + | ppoint: S → pitem S + | pconcat: pitem S → pitem S → pitem S + | por: pitem S → pitem S → pitem S + | pstar: pitem S → pitem S. -ndefinition pre ≝ λS.pitem S × bool. - -interpretation "pstar" 'pk a = (pk ? a). -interpretation "por" 'plus a b = (po ? a b). -interpretation "pcat" 'pc a b = (pc ? a b). -notation < ".a" non associative with precedence 90 for @{ 'pp $a}. -notation > "`. term 90 a" non associative with precedence 90 for @{ 'pp $a}. -interpretation "ppatom" 'pp a = (pp ? a). -(* to get rid of \middot *) -ncoercion pc : ∀S.∀p:pitem S. pitem S → pitem S ≝ pc on _p : pitem ? to ∀_:?.?. -interpretation "patom" 'ps a = (ps ? a). -interpretation "pepsilon" 'epsilon = (pe ?). -interpretation "pempty" 'empty = (pz ?). - -notation > "|term 19 e|" non associative with precedence 70 for @{forget ? $e}. -nlet rec forget (S: Alpha) (l : pitem S) on l: re S ≝ +definition pre ≝ λS.a href="cic:/matita/tutorial/chapter4/pitem.ind(1,0,1)"pitem/a S a title="Product" href="cic:/fakeuri.def(1)"×/a a href="cic:/matita/basics/bool/bool.ind(1,0,0)" title="null"bool/a. + +interpretation "pstar" 'kstar a = (pstar ? a). +interpretation "por" 'plus a b = (por ? a b). +interpretation "pcat" 'concat a b = (pconcat ? a b). + +notation "• a" non associative with precedence 90 for @{ 'ppoint $a}. +(* notation > "`. term 90 a" non associative with precedence 90 for @{ 'pp $a}. *) + +interpretation "ppatom" 'ppoint a = (ppoint ? a). +(* to get rid of \middot +ncoercion pc : ∀S.∀p:pitem S. pitem S → pitem S ≝ pc on _p : pitem ? to ∀_:?.?. *) +interpretation "patom" 'pchar a = (pchar ? a). +interpretation "pepsilon" 'epsilon = (pepsilon ?). +interpretation "pempty" 'empty = (pzero ?). + +notation "\boxv term 19 e \boxv" (* slash boxv *) non associative with precedence 70 for @{forget ? $e}. + +let rec forget (S: a href="cic:/matita/tutorial/chapter4/Alpha.ind(1,0,0)"Alpha/a) (l : a href="cic:/matita/tutorial/chapter4/pitem.ind(1,0,1)"pitem/a S) on l: a href="cic:/matita/tutorial/chapter4/re.ind(1,0,1)"re/a S ≝ match l with - [ pz ⇒ ∅ - | pe ⇒ ϵ - | ps x ⇒ `x - | pp x ⇒ `x - | pc E1 E2 ⇒ (|E1| · |E2|) - | po E1 E2 ⇒ (|E1| + |E2|) - | pk E ⇒ |E|^* ]. + [ pzero ⇒ a title="empty" href="cic:/fakeuri.def(1)"∅/a + | pepsilon ⇒ a title="epsilon" href="cic:/fakeuri.def(1)"ϵ/a + | pchar x ⇒ a href="cic:/matita/tutorial/chapter4/re.con(0,3,1)"char/a ? x + | ppoint x ⇒ a href="cic:/matita/tutorial/chapter4/re.con(0,3,1)"char/a ? x + | pconcat e1 e2 ⇒ │e1│ a title="cat" href="cic:/fakeuri.def(1)"·/a │e2│ + | por e1 e2 ⇒ │e1│ a title="or" href="cic:/fakeuri.def(1)"+/a │e2│ + | pstar e ⇒ │e│a title="star" href="cic:/fakeuri.def(1)"^/a* + ]. + notation < "|term 19 e|" non associative with precedence 70 for @{'forget $e}. interpretation "forget" 'forget a = (forget ? a). -notation "\fst term 90 x" non associative with precedence 90 for @{'fst $x}. \ No newline at end of file + +notation "\fst term 90 x" non associative with precedence 90 for @{'fst $x}.