src/HOL/Tools/hologic.ML
changeset 46216 7fcdb5562461
parent 45977 e3accf78bb07
child 47108 2a1953f0d20d
equal deleted inserted replaced
46215:0da9433f959e 46216:7fcdb5562461
   253 fun mk_eq (t, u) = eq_const (fastype_of t) $ t $ u;
   253 fun mk_eq (t, u) = eq_const (fastype_of t) $ t $ u;
   254 
   254 
   255 fun dest_eq (Const ("HOL.eq", _) $ lhs $ rhs) = (lhs, rhs)
   255 fun dest_eq (Const ("HOL.eq", _) $ lhs $ rhs) = (lhs, rhs)
   256   | dest_eq t = raise TERM ("dest_eq", [t])
   256   | dest_eq t = raise TERM ("dest_eq", [t])
   257 
   257 
   258 fun all_const T = Const ("HOL.All", [T --> boolT] ---> boolT);
   258 fun all_const T = Const ("HOL.All", (T --> boolT) --> boolT);
   259 fun mk_all (x, T, P) = all_const T $ absfree (x, T) P;
   259 fun mk_all (x, T, P) = all_const T $ absfree (x, T) P;
   260 fun list_all (xs, t) = fold_rev (fn (x, T) => fn P => all_const T $ Abs (x, T, P)) xs t;
   260 fun list_all (xs, t) = fold_rev (fn (x, T) => fn P => all_const T $ Abs (x, T, P)) xs t;
   261 
   261 
   262 fun exists_const T = Const ("HOL.Ex", [T --> boolT] ---> boolT);
   262 fun exists_const T = Const ("HOL.Ex", (T --> boolT) --> boolT);
   263 fun mk_exists (x, T, P) = exists_const T $ absfree (x, T) P;
   263 fun mk_exists (x, T, P) = exists_const T $ absfree (x, T) P;
   264 
   264 
   265 fun choice_const T = Const("Hilbert_Choice.Eps", (T --> boolT) --> T);
   265 fun choice_const T = Const("Hilbert_Choice.Eps", (T --> boolT) --> T);
   266 
   266 
   267 val class_equal = "HOL.equal";
   267 val class_equal = "HOL.equal";
   268 
   268 
   269 
   269 
   270 (* binary operations and relations *)
   270 (* binary operations and relations *)
   271 
   271 
   272 fun mk_binop c (t, u) =
   272 fun mk_binop c (t, u) =
   273   let val T = fastype_of t in
   273   let val T = fastype_of t
   274     Const (c, [T, T] ---> T) $ t $ u
   274   in Const (c, T --> T --> T) $ t $ u end;
   275   end;
       
   276 
   275 
   277 fun mk_binrel c (t, u) =
   276 fun mk_binrel c (t, u) =
   278   let val T = fastype_of t in
   277   let val T = fastype_of t
   279     Const (c, [T, T] ---> boolT) $ t $ u
   278   in Const (c, T --> T --> boolT) $ t $ u end;
   280   end;
       
   281 
   279 
   282 (*destruct the application of a binary operator. The dummyT case is a crude
   280 (*destruct the application of a binary operator. The dummyT case is a crude
   283   way of handling polymorphic operators.*)
   281   way of handling polymorphic operators.*)
   284 fun dest_bin c T (tm as Const (c', Type ("fun", [T', _])) $ t $ u) =
   282 fun dest_bin c T (tm as Const (c', Type ("fun", [T', _])) $ t $ u) =
   285       if c = c' andalso (T=T' orelse T=dummyT) then (t, u)
   283       if c = c' andalso (T=T' orelse T=dummyT) then (t, u)
   305 fun mk_prodT (T1, T2) = Type ("Product_Type.prod", [T1, T2]);
   303 fun mk_prodT (T1, T2) = Type ("Product_Type.prod", [T1, T2]);
   306 
   304 
   307 fun dest_prodT (Type ("Product_Type.prod", [T1, T2])) = (T1, T2)
   305 fun dest_prodT (Type ("Product_Type.prod", [T1, T2])) = (T1, T2)
   308   | dest_prodT T = raise TYPE ("dest_prodT", [T], []);
   306   | dest_prodT T = raise TYPE ("dest_prodT", [T], []);
   309 
   307 
   310 fun pair_const T1 T2 = Const ("Product_Type.Pair", [T1, T2] ---> mk_prodT (T1, T2));
   308 fun pair_const T1 T2 = Const ("Product_Type.Pair", T1 --> T2 --> mk_prodT (T1, T2));
   311 
   309 
   312 fun mk_prod (t1, t2) =
   310 fun mk_prod (t1, t2) =
   313   let val T1 = fastype_of t1 and T2 = fastype_of t2 in
   311   let val T1 = fastype_of t1 and T2 = fastype_of t2 in
   314     pair_const T1 T2 $ t1 $ t2
   312     pair_const T1 T2 $ t1 $ t2
   315   end;
   313   end;