864 case polar of |
864 case polar of |
865 Neg => kk_not (kk_rel_eq r (KK.Atom j0)) |
865 Neg => kk_not (kk_rel_eq r (KK.Atom j0)) |
866 | _ => kk_rel_eq r (KK.Atom (j0 + 1)) |
866 | _ => kk_rel_eq r (KK.Atom (j0 + 1)) |
867 val formula_from_atom = formula_from_opt_atom Pos |
867 val formula_from_atom = formula_from_opt_atom Pos |
868 |
868 |
869 fun kk_notimplies f1 f2 = kk_and f1 (kk_not f2) |
|
870 val kk_or3 = |
|
871 double_rel_rel_let kk |
|
872 (fn r1 => fn r2 => |
|
873 kk_rel_if (kk_subset true_atom (kk_union r1 r2)) true_atom |
|
874 (kk_intersect r1 r2)) |
|
875 val kk_and3 = |
|
876 double_rel_rel_let kk |
|
877 (fn r1 => fn r2 => |
|
878 kk_rel_if (kk_subset false_atom (kk_union r1 r2)) false_atom |
|
879 (kk_intersect r1 r2)) |
|
880 fun kk_notimplies3 r1 r2 = kk_and3 r1 (kk_not3 r2) |
|
881 |
|
882 val unpack_formulas = |
869 val unpack_formulas = |
883 map (formula_from_atom bool_j0) oo unpack_vect_in_chunks kk 1 |
870 map (formula_from_atom bool_j0) oo unpack_vect_in_chunks kk 1 |
884 fun kk_vect_set_op connective k r1 r2 = |
|
885 fold1 kk_product (map2 (atom_from_formula kk bool_j0 oo connective) |
|
886 (unpack_formulas k r1) (unpack_formulas k r2)) |
|
887 fun kk_vect_set_bool_op connective k r1 r2 = |
871 fun kk_vect_set_bool_op connective k r1 r2 = |
888 fold1 kk_and (map2 connective (unpack_formulas k r1) |
872 fold1 kk_and (map2 connective (unpack_formulas k r1) |
889 (unpack_formulas k r2)) |
873 (unpack_formulas k r2)) |
890 |
874 |
891 fun to_f u = |
875 fun to_f u = |
1367 atom_from_formula kk j0 f1 |
1351 atom_from_formula kk j0 f1 |
1368 else |
1352 else |
1369 kk_union (kk_rel_if f1 true_atom KK.None) |
1353 kk_union (kk_rel_if f1 true_atom KK.None) |
1370 (kk_rel_if f2 KK.None false_atom) |
1354 (kk_rel_if f2 KK.None false_atom) |
1371 end |
1355 end |
1372 | Op2 (Union, _, R, u1, u2) => |
|
1373 to_set_op kk_or kk_or3 kk_union kk_union kk_intersect false R u1 u2 |
|
1374 | Op2 (SetDifference, _, R, u1, u2) => |
|
1375 to_set_op kk_notimplies kk_notimplies3 kk_difference kk_intersect |
|
1376 kk_union true R u1 u2 |
|
1377 | Op2 (Intersect, _, R, u1, u2) => |
|
1378 to_set_op kk_and kk_and3 kk_intersect kk_intersect kk_union false R |
|
1379 u1 u2 |
|
1380 | Op2 (Composition, _, R, u1, u2) => |
1356 | Op2 (Composition, _, R, u1, u2) => |
1381 let |
1357 let |
1382 val (a_T, b_T) = HOLogic.dest_prodT (domain_type (type_of u1)) |
1358 val (a_T, b_T) = HOLogic.dest_prodT (domain_type (type_of u1)) |
1383 val (_, c_T) = HOLogic.dest_prodT (domain_type (type_of u2)) |
1359 val (_, c_T) = HOLogic.dest_prodT (domain_type (type_of u2)) |
1384 val ab_k = card_of_domain_from_rep 2 (rep_of u1) |
1360 val ab_k = card_of_domain_from_rep 2 (rep_of u1) |
1642 connective (formula_from_atom j0 r1) (formula_from_atom j0 r2) |
1618 connective (formula_from_atom j0 r1) (formula_from_atom j0 r2) |
1643 | Func (_, Atom _) => set_oper (kk_join r1 true_atom) |
1619 | Func (_, Atom _) => set_oper (kk_join r1 true_atom) |
1644 (kk_join r2 true_atom) |
1620 (kk_join r2 true_atom) |
1645 | _ => raise REP ("Nitpick_Kodkod.to_set_bool_op", [min_R]) |
1621 | _ => raise REP ("Nitpick_Kodkod.to_set_bool_op", [min_R]) |
1646 end |
1622 end |
1647 and to_set_op connective connective3 set_oper true_set_oper false_set_oper |
|
1648 neg_second R u1 u2 = |
|
1649 let |
|
1650 val min_R = min_rep (rep_of u1) (rep_of u2) |
|
1651 val r1 = to_rep min_R u1 |
|
1652 val r2 = to_rep min_R u2 |
|
1653 val unopt_R = unopt_rep R |
|
1654 in |
|
1655 rel_expr_from_rel_expr kk unopt_R (unopt_rep min_R) |
|
1656 (case min_R of |
|
1657 Opt (Vect (k, Atom _)) => kk_vect_set_op connective k r1 r2 |
|
1658 | Vect (k, Atom _) => kk_vect_set_op connective k r1 r2 |
|
1659 | Func (_, Formula Neut) => set_oper r1 r2 |
|
1660 | Func (Unit, _) => connective3 r1 r2 |
|
1661 | Func _ => |
|
1662 double_rel_rel_let kk |
|
1663 (fn r1 => fn r2 => |
|
1664 kk_union |
|
1665 (kk_product |
|
1666 (true_set_oper (kk_join r1 true_atom) |
|
1667 (kk_join r2 (atom_for_bool bool_j0 |
|
1668 (not neg_second)))) |
|
1669 true_atom) |
|
1670 (kk_product |
|
1671 (false_set_oper (kk_join r1 false_atom) |
|
1672 (kk_join r2 (atom_for_bool bool_j0 |
|
1673 neg_second))) |
|
1674 false_atom)) |
|
1675 r1 r2 |
|
1676 | _ => raise REP ("Nitpick_Kodkod.to_set_op", [min_R])) |
|
1677 end |
|
1678 and to_bit_word_unary_op T R oper = |
1623 and to_bit_word_unary_op T R oper = |
1679 let |
1624 let |
1680 val Ts = strip_type T ||> single |> op @ |
1625 val Ts = strip_type T ||> single |> op @ |
1681 fun int_arg j = int_expr_from_atom kk (nth Ts j) (KK.Var (1, j)) |
1626 fun int_arg j = int_expr_from_atom kk (nth Ts j) (KK.Var (1, j)) |
1682 in |
1627 in |