# HG changeset patch # User blanchet # Date 1346852426 -7200 # Node ID ba50a6853a6c5419657badddabc8aaf63e43da70 # Parent 6407346b74c76f92b1b345a051ab87f9546460dd ported "Misc_Codata" to new syntax diff -r 6407346b74c7 -r ba50a6853a6c src/HOL/Codatatype/Examples/Misc_Codata.thy --- a/src/HOL/Codatatype/Examples/Misc_Codata.thy Wed Sep 05 15:40:13 2012 +0200 +++ b/src/HOL/Codatatype/Examples/Misc_Codata.thy Wed Sep 05 15:40:26 2012 +0200 @@ -12,55 +12,56 @@ imports "../Codatatype" begin -codata_raw simple: 'a = "unit + unit + unit + unit" +codata simple = X1 | X2 | X3 | X4 + +codata simple' = X1' unit | X2' unit | X3' unit | X4' unit -codata_raw stream: 's = "'a \ 's" +codata 'a stream = Stream 'a "'a stream" + +codata 'a mylist = MyNil | MyCons 'a "'a mylist" + +codata ('b, 'c, 'd, 'e) some_passive = + SP1 "('b, 'c, 'd, 'e) some_passive" | SP2 'b | SP3 'c | SP4 'd | SP5 'e -codata_raw llist: 'llist = "unit + 'a \ 'llist" +codata lambda = + Var string | + App lambda lambda | + Abs string lambda | + Let "(string \ lambda) fset" lambda -codata_raw some_passive: 'a = "'a + 'b + 'c + 'd + 'e" +codata 'a par_lambda = + PVar 'a | + PApp "'a par_lambda" "'a par_lambda" | + PAbs 'a "'a par_lambda" | + PLet "('a \ 'a par_lambda) fset" "'a par_lambda" (* ('a, 'b1, 'b2) F1 = 'a * 'b1 + 'a * 'b2 ('a, 'b1, 'b2) F2 = unit + 'b1 * 'b2 *) -codata_raw F1: 'b1 = "'a \ 'b1 + 'a \ 'b2" -and F2: 'b2 = "unit + 'b1 * 'b2" +codata 'a J1 = J11 'a "'a J1" | J12 'a "'a J2" + and 'a J2 = J21 | J22 "'a J1" "'a J2" -codata_raw EXPR: 'E = "'T + 'T \ 'E" -and TERM: 'T = "'F + 'F \ 'T" -and FACTOR: 'F = "'a + 'b + 'E" +codata 'a tree = TEmpty | TNode 'a "'a forest" + and 'a forest = FNil | FCons "'a tree" "'a forest" -codata_raw llambda: - 'trm = "string + - 'trm \ 'trm + - string \ 'trm + - (string \ 'trm) fset \ 'trm" +codata 'a tree' = TEmpty' | TNode' "'a branch" "'a branch" + and 'a branch = Branch 'a "'a tree'" -codata_raw par_llambda: - 'trm = "'a + - 'trm \ 'trm + - 'a \ 'trm + - ('a \ 'trm) fset \ 'trm" +codata ('a, 'b) exp = Term "('a, 'b) trm" | Sum "('a, 'b) trm" "('a, 'b) exp" + and ('a, 'b) trm = Factor "('a, 'b) factor" | Prod "('a, 'b) factor" "('a, 'b) trm" + and ('a, 'b) factor = C 'a | V 'b | Paren "('a, 'b) exp" -(* - 'a tree = Empty | Node of 'a * 'a forest ('b = unit + 'a * 'c) - 'a forest = Nil | Cons of 'a tree * 'a forest ('c = unit + 'b * 'c) -*) +codata_raw some_killing: 'A = "'a \ 'b \ ('A + 'B)" + and in_here: 'B = "'b \ 'a + 'c" -codata_raw tree: 'tree = "unit + 'a \ 'forest" -and forest: 'forest = "unit + 'tree \ 'forest" - -codata_raw CPS: 'a = "'b + 'b \ 'a" - -codata_raw fun_rhs: 'a = "'b1 \ 'b2 \ 'b3 \ 'b4 \ 'b5 \ 'b6 \ 'b7 \ 'b8 \ 'b9 \ 'a" - -codata_raw fun_rhs': 'a = "'b1 \ 'b2 \ 'b3 \ 'b4 \ 'b5 \ 'b6 \ 'b7 \ 'b8 \ 'b9 \ 'b10 \ - 'b11 \ 'b12 \ 'b13 \ 'b14 \ 'b15 \ 'b16 \ 'b17 \ 'b18 \ 'b19 \ 'b20 \ 'a" - -codata_raw some_killing: 'a = "'b \ 'd \ ('a + 'c)" -and in_here: 'c = "'d \ 'b + 'e" +(* FIXME +codata ('a, 'b, 'c) some_killing = + SK "'a \ 'b \ ('a, 'b, 'c) some_killing + ('a, 'b, 'c) in_here" + and ('a, 'b, 'c) in_here = + IH1 'b 'a | IH2 'c +*) codata_raw some_killing': 'a = "'b \ 'd \ ('a + 'c)" and in_here': 'c = "'d + 'e" @@ -70,25 +71,39 @@ codata_raw less_killing: 'a = "'b \ 'c" -codata_raw - wit3_F1: 'b1 = "'a1 \ 'b1 \ 'b2" -and wit3_F2: 'b2 = "'a2 \ 'b2" -and wit3_F3: 'b3 = "'a1 \ 'a2 \ 'b1 + 'a3 \ 'a1 \ 'a2 \ 'b1" +codata 'b cps = CPS1 'b | CPS2 "'b \ 'b cps" + +codata ('b1, 'b2, 'b3, 'b4, 'b5, 'b6, 'b7, 'b8, 'b9) fun_rhs = + FR "'b1 \ 'b2 \ 'b3 \ 'b4 \ 'b5 \ 'b6 \ 'b7 \ 'b8 \ 'b9 \ + ('b1, 'b2, 'b3, 'b4, 'b5, 'b6, 'b7, 'b8, 'b9) fun_rhs" -codata_raw - coind_wit1: 'a = "'c \ 'a \ 'b \ 'd" -and coind_wit2: 'd = "'d \ 'e + 'c \ 'g" -and ind_wit: 'b = "unit + 'c" +codata ('b1, 'b2, 'b3, 'b4, 'b5, 'b6, 'b7, 'b8, 'b9, 'b10, 'b11, 'b12, 'b13, 'b14, 'b15, 'b16, 'b17, + 'b18, 'b19, 'b20) fun_rhs' = + FR' "'b1 \ 'b2 \ 'b3 \ 'b4 \ 'b5 \ 'b6 \ 'b7 \ 'b8 \ 'b9 \ 'b10 \ 'b11 \ 'b12 \ 'b13 \ 'b14 \ + 'b15 \ 'b16 \ 'b17 \ 'b18 \ 'b19 \ 'b20 \ + ('b1, 'b2, 'b3, 'b4, 'b5, 'b6, 'b7, 'b8, 'b9, 'b10, 'b11, 'b12, 'b13, 'b14, 'b15, 'b16, 'b17, + 'b18, 'b19, 'b20) fun_rhs'" + +codata ('a, 'b, 'c) wit3_F1 = W1 'a "('a, 'b, 'c) wit3_F1" "('a, 'b, 'c) wit3_F2" + and ('a, 'b, 'c) wit3_F2 = W2 'b "('a, 'b, 'c) wit3_F2" + and ('a, 'b, 'c) wit3_F3 = W31 'a 'b "('a, 'b, 'c) wit3_F1" | W32 'c 'a 'b "('a, 'b, 'c) wit3_F1" + +codata ('c, 'e, 'g) coind_wit1 = + CW1 'c "('c, 'e, 'g) coind_wit1" "('c, 'e, 'g) ind_wit" "('c, 'e, 'g) coind_wit2" + and ('c, 'e, 'g) coind_wit2 = + CW21 "('c, 'e, 'g) coind_wit2" 'e | CW22 'c 'g + and ('c, 'e, 'g) ind_wit = + IW1 | IW2 'c (* SLOW, MEMORY-HUNGRY -codata_raw K1': 'K1 = "'K2 + 'a list" -and K2': 'K2 = "'K3 + 'c fset" -and K3': 'K3 = "'K3 + 'K4 + 'K4 \ 'K5" -and K4': 'K4 = "'K5 + 'a list list list" -and K5': 'K5 = "'K6" -and K6': 'K6 = "'K7" -and K7': 'K7 = "'K8" -and K8': 'K8 = "'K1 list" +codata ('a, 'c) D1 = A1 "('a, 'c) D2" | B1 "'a list" + and ('a, 'c) D2 = A2 "('a, 'c) D3" | B2 "'c list" + and ('a, 'c) D3 = A3 "('a, 'c) D3" | B3 "('a, 'c) D4" | C3 "('a, 'c) D4" "('a, 'c) D5" + and ('a, 'c) D4 = A4 "('a, 'c) D5" | B4 "'a list list list" + and ('a, 'c) D5 = A5 "('a, 'c) D6" + and ('a, 'c) D6 = A6 "('a, 'c) D7" + and ('a, 'c) D7 = A7 "('a, 'c) D8" + and ('a, 'c) D8 = A8 "('a, 'c) D1 list" *) end diff -r 6407346b74c7 -r ba50a6853a6c src/HOL/Codatatype/Examples/Misc_Data.thy --- a/src/HOL/Codatatype/Examples/Misc_Data.thy Wed Sep 05 15:40:13 2012 +0200 +++ b/src/HOL/Codatatype/Examples/Misc_Data.thy Wed Sep 05 15:40:26 2012 +0200 @@ -52,7 +52,7 @@ and ('a, 'b) factor = C 'a | V 'b | Paren "('a, 'b) exp" data_raw some_killing: 'A = "'a \ 'b \ ('A + 'B)" -and in_here: 'B = "'b \ 'a + 'c" + and in_here: 'B = "'b \ 'a + 'c" (* FIXME data ('a, 'b, 'c) some_killing =