470 fun try_classes tycon = (tycon, fold (add_class tycon) cls []) |
470 fun try_classes tycon = (tycon, fold (add_class tycon) cls []) |
471 in map try_classes tycons end |
471 in map try_classes tycons end |
472 |
472 |
473 (* Proving one (tycon, class) membership may require proving others, so |
473 (* Proving one (tycon, class) membership may require proving others, so |
474 iterate. *) |
474 iterate. *) |
475 fun all_class_pairs _ _ [] = ([], []) |
475 fun all_class_pairs _ _ _ [] = ([], []) |
476 | all_class_pairs thy tycons cls = |
476 | all_class_pairs thy tycons old_cls cls = |
477 let |
477 let |
478 fun maybe_insert_class s = |
478 val old_cls' = cls @ old_cls |
479 (s <> class_of_types andalso not (member (op =) cls s)) ? insert (op =) s |
479 fun maybe_insert_class s = not (member (op =) old_cls' s) ? insert (op =) s |
|
480 |
480 val pairs = class_pairs thy tycons cls |
481 val pairs = class_pairs thy tycons cls |
481 val new_cls = |
482 val new_cls = fold (fold (fold (fold maybe_insert_class) o snd) o snd) pairs [] |
482 [] |> fold (fold (fold (fold maybe_insert_class) o snd) o snd) pairs |
483 val (cls', pairs') = all_class_pairs thy tycons old_cls' new_cls |
483 val (cls', pairs') = all_class_pairs thy tycons new_cls |
|
484 in (cls' @ cls, union (op =) pairs' pairs) end |
484 in (cls' @ cls, union (op =) pairs' pairs) end |
485 |
485 |
486 fun tcon_clause _ _ [] = [] |
486 fun tcon_clause _ _ [] = [] |
487 | tcon_clause seen n ((_, []) :: rest) = tcon_clause seen n rest |
487 | tcon_clause seen n ((_, []) :: rest) = tcon_clause seen n rest |
488 | tcon_clause seen n ((tcons, (ar as (cl, _)) :: ars) :: rest) = |
488 | tcon_clause seen n ((tcons, (ar as (cl, _)) :: ars) :: rest) = |
496 else |
496 else |
497 make_axiom_tcon_clause (tcons, lookup_const tcons ^ "___" ^ ascii_of cl, ar) :: |
497 make_axiom_tcon_clause (tcons, lookup_const tcons ^ "___" ^ ascii_of cl, ar) :: |
498 tcon_clause (cl :: seen) n ((tcons, ars) :: rest) |
498 tcon_clause (cl :: seen) n ((tcons, ars) :: rest) |
499 |
499 |
500 fun make_tcon_clauses thy tycons = |
500 fun make_tcon_clauses thy tycons = |
501 all_class_pairs thy tycons ##> tcon_clause [] 1 |
501 all_class_pairs thy tycons [] ##> tcon_clause [] 1 |
502 |
502 |
503 |
503 |
504 (** Isabelle class relations **) |
504 (** Isabelle class relations **) |
505 |
505 |
506 (* Generate a list ("sub", "supers") such that "sub" is a proper subclass of all |
506 (* Generate a list ("sub", "supers") such that "sub" is a proper subclass of all |