src/HOL/Tools/Nitpick/nitpick_kodkod.ML
changeset 35072 d79308423aea
parent 35070 96136eb6218f
child 35078 6fd1052fe463
equal deleted inserted replaced
35071:3df45b0ce819 35072:d79308423aea
   314        else
   314        else
   315          let val ts = KK.TupleAtomSeq (epsilon - delta, delta + j0) in
   315          let val ts = KK.TupleAtomSeq (epsilon - delta, delta + j0) in
   316            if R2 = Formula Neut then
   316            if R2 = Formula Neut then
   317              [ts] |> not exclusive ? cons (KK.TupleSet [])
   317              [ts] |> not exclusive ? cons (KK.TupleSet [])
   318            else
   318            else
   319              [KK.TupleSet [], KK.TupleProduct (ts, upper_bound_for_rep R2)]
   319              [KK.TupleSet [],
       
   320               if exclusive andalso T1 = T2 andalso epsilon > delta then
       
   321                 index_seq delta (epsilon - delta)
       
   322                 |> map (fn j =>
       
   323                            KK.TupleProduct (KK.TupleSet [Kodkod.Tuple [j + j0]],
       
   324                                             KK.TupleAtomSeq (j, j0)))
       
   325                 |> foldl1 KK.TupleUnion
       
   326               else
       
   327                 KK.TupleProduct (ts, upper_bound_for_rep R2)]
   320          end)
   328          end)
   321     end
   329     end
   322   | bound_for_sel_rel _ _ _ u =
   330   | bound_for_sel_rel _ _ _ u =
   323     raise NUT ("Nitpick_Kodkod.bound_for_sel_rel", [u])
   331     raise NUT ("Nitpick_Kodkod.bound_for_sel_rel", [u])
   324 
   332 
   942   maps (other_axioms_for_datatype hol_ctxt bits ofs kk rel_table) dtypes
   950   maps (other_axioms_for_datatype hol_ctxt bits ofs kk rel_table) dtypes
   943 
   951 
   944 (* int -> int Typtab.table -> bool -> kodkod_constrs -> nut -> KK.formula *)
   952 (* int -> int Typtab.table -> bool -> kodkod_constrs -> nut -> KK.formula *)
   945 fun kodkod_formula_from_nut bits ofs liberal
   953 fun kodkod_formula_from_nut bits ofs liberal
   946         (kk as {kk_all, kk_exist, kk_formula_let, kk_formula_if, kk_or, kk_not,
   954         (kk as {kk_all, kk_exist, kk_formula_let, kk_formula_if, kk_or, kk_not,
   947                 kk_iff, kk_implies, kk_and, kk_subset, kk_rel_eq, kk_no, kk_one,
   955                 kk_iff, kk_implies, kk_and, kk_subset, kk_rel_eq, kk_no,
   948                 kk_some, kk_rel_let, kk_rel_if, kk_union, kk_difference,
   956                 kk_lone, kk_one, kk_some, kk_rel_let, kk_rel_if, kk_union,
   949                 kk_intersect, kk_product, kk_join, kk_closure, kk_comprehension,
   957                 kk_difference, kk_intersect, kk_product, kk_join, kk_closure,
   950                 kk_project, kk_project_seq, kk_not3, kk_nat_less, kk_int_less,
   958                 kk_comprehension, kk_project, kk_project_seq, kk_not3,
   951                 ...}) u =
   959                 kk_nat_less, kk_int_less, ...}) u =
   952   let
   960   let
   953     val main_j0 = offset_of_type ofs bool_T
   961     val main_j0 = offset_of_type ofs bool_T
   954     val bool_j0 = main_j0
   962     val bool_j0 = main_j0
   955     val bool_atom_R = Atom (2, main_j0)
   963     val bool_atom_R = Atom (2, main_j0)
   956     val false_atom = KK.Atom bool_j0
   964     val false_atom = KK.Atom bool_j0
  1106                        else
  1114                        else
  1107                          raise SAME ()
  1115                          raise SAME ()
  1108                      else
  1116                      else
  1109                        if is_lone_rep min_R then
  1117                        if is_lone_rep min_R then
  1110                          if arity_of_rep min_R = 1 then
  1118                          if arity_of_rep min_R = 1 then
  1111                            kk_subset (kk_product r1 r2) KK.Iden
  1119                            kk_lone (kk_union r1 r2)
  1112                          else if not both_opt then
  1120                          else if not both_opt then
  1113                            (r1, r2) |> is_opt_rep (rep_of u2) ? swap
  1121                            (r1, r2) |> is_opt_rep (rep_of u2) ? swap
  1114                                     |-> kk_subset
  1122                                     |-> kk_subset
  1115                          else
  1123                          else
  1116                            raise SAME ()
  1124                            raise SAME ()