42 "@Finset" :: "args => 'a set" ("{(_)}") |
42 "@Finset" :: "args => 'a set" ("{(_)}") |
43 |
43 |
44 |
44 |
45 (** Binding Constants **) |
45 (** Binding Constants **) |
46 |
46 |
47 "@Coll" :: "[idt, bool] => 'a set" ("(1{_./ _})") (*collection*) |
47 "@Coll" :: "[idt, bool] => 'a set" ("(1{_./ _})") |
|
48 "@SetCompr" :: "['a, idts, bool] => 'a set" ("{_ |/_./ _}") |
48 |
49 |
49 (* Big Intersection / Union *) |
50 (* Big Intersection / Union *) |
50 |
51 |
51 "@INTER" :: "[idt, 'a set, 'b set] => 'b set" ("(3INT _:_./ _)" 10) |
52 "@INTER" :: "[idt, 'a set, 'b set] => 'b set" ("(3INT _:_./ _)" 10) |
52 "@UNION" :: "[idt, 'a set, 'b set] => 'b set" ("(3UN _:_./ _)" 10) |
53 "@UNION" :: "[idt, 'a set, 'b set] => 'b set" ("(3UN _:_./ _)" 10) |
102 inj_onto_def "inj_onto(f, A) == ! x:A. ! y:A. f(x)=f(y) --> x=y" |
103 inj_onto_def "inj_onto(f, A) == ! x:A. ! y:A. f(x)=f(y) --> x=y" |
103 surj_def "surj(f) == ! y. ? x. y=f(x)" |
104 surj_def "surj(f) == ! y. ? x. y=f(x)" |
104 |
105 |
105 end |
106 end |
106 |
107 |
|
108 ML |
107 |
109 |
108 ML |
110 local |
|
111 |
|
112 (* Translates between { e | x1..xn. P} and {u. ? x1..xn. u=e & P} *) |
|
113 |
|
114 fun dummyC(s) = Const(s,dummyT); |
|
115 |
|
116 val ex_tr = snd(mk_binder_tr("? ","Ex")); |
|
117 |
|
118 fun nvars(Const("_idts",_) $ _ $ idts) = nvars(idts)+1 |
|
119 | nvars(_) = 1; |
|
120 |
|
121 fun setcompr_tr[e,idts,b] = |
|
122 let val eq = dummyC("op =") $ Bound(nvars(idts)) $ e |
|
123 val P = dummyC("op &") $ eq $ b |
|
124 val exP = ex_tr [idts,P] |
|
125 in dummyC("Collect") $ Abs("",dummyT,exP) end; |
|
126 |
|
127 val ex_tr' = snd(mk_binder_tr' ("Ex","DUMMY")); |
|
128 |
|
129 fun setcompr_tr'[Abs(_,_,P)] = |
|
130 let fun ok(Const("Ex",_)$Abs(_,_,P),n) = ok(P,n+1) |
|
131 | ok(Const("op &",_) $ (Const("op =",_) $ Bound(m) $ _) $ _, n) = |
|
132 if n>0 andalso m=n then () else raise Match |
|
133 |
|
134 fun tr'(_ $ abs) = |
|
135 let val _ $ idts $ (_ $ (_ $ _ $ e) $ Q) = ex_tr'[abs] |
|
136 in dummyC("@SetCompr") $ e $ idts $ Q end |
|
137 in ok(P,0); tr'(P) end; |
|
138 |
|
139 in |
|
140 |
|
141 val parse_translation = [("@SetCompr",setcompr_tr)]; |
|
142 val print_translation = [("Collect",setcompr_tr')]; |
109 |
143 |
110 val print_ast_translation = |
144 val print_ast_translation = |
111 map HOL.alt_ast_tr' [("@Ball", "*Ball"), ("@Bex", "*Bex")]; |
145 map HOL.alt_ast_tr' [("@Ball", "*Ball"), ("@Bex", "*Bex")]; |
112 |
146 |
|
147 end; |
|
148 |