src/HOL/Tools/Nitpick/minipick.ML
changeset 37678 0040bafffdef
parent 37396 18a1e9c7acb0
child 38190 b02e204b613a
equal deleted inserted replaced
37677:c5a8b612e571 37678:0040bafffdef
    35 
    35 
    36 datatype rep = SRep | RRep
    36 datatype rep = SRep | RRep
    37 
    37 
    38 fun check_type ctxt (Type (@{type_name fun}, Ts)) =
    38 fun check_type ctxt (Type (@{type_name fun}, Ts)) =
    39     List.app (check_type ctxt) Ts
    39     List.app (check_type ctxt) Ts
    40   | check_type ctxt (Type (@{type_name "*"}, Ts)) =
    40   | check_type ctxt (Type (@{type_name Product_Type.prod}, Ts)) =
    41     List.app (check_type ctxt) Ts
    41     List.app (check_type ctxt) Ts
    42   | check_type _ @{typ bool} = ()
    42   | check_type _ @{typ bool} = ()
    43   | check_type _ (TFree (_, @{sort "{}"})) = ()
    43   | check_type _ (TFree (_, @{sort "{}"})) = ()
    44   | check_type _ (TFree (_, @{sort HOL.type})) = ()
    44   | check_type _ (TFree (_, @{sort HOL.type})) = ()
    45   | check_type ctxt T =
    45   | check_type ctxt T =
    49     replicate_list (card T1) (atom_schema_of SRep card T2)
    49     replicate_list (card T1) (atom_schema_of SRep card T2)
    50   | atom_schema_of RRep card (Type (@{type_name fun}, [T1, @{typ bool}])) =
    50   | atom_schema_of RRep card (Type (@{type_name fun}, [T1, @{typ bool}])) =
    51     atom_schema_of SRep card T1
    51     atom_schema_of SRep card T1
    52   | atom_schema_of RRep card (Type (@{type_name fun}, [T1, T2])) =
    52   | atom_schema_of RRep card (Type (@{type_name fun}, [T1, T2])) =
    53     atom_schema_of SRep card T1 @ atom_schema_of RRep card T2
    53     atom_schema_of SRep card T1 @ atom_schema_of RRep card T2
    54   | atom_schema_of _ card (Type (@{type_name "*"}, Ts)) =
    54   | atom_schema_of _ card (Type (@{type_name Product_Type.prod}, Ts)) =
    55     maps (atom_schema_of SRep card) Ts
    55     maps (atom_schema_of SRep card) Ts
    56   | atom_schema_of _ card T = [card T]
    56   | atom_schema_of _ card T = [card T]
    57 val arity_of = length ooo atom_schema_of
    57 val arity_of = length ooo atom_schema_of
    58 
    58 
    59 fun index_for_bound_var _ [_] 0 = 0
    59 fun index_for_bound_var _ [_] 0 = 0
   288 fun kodkod_problem_from_term ctxt raw_card t =
   288 fun kodkod_problem_from_term ctxt raw_card t =
   289   let
   289   let
   290     val thy = ProofContext.theory_of ctxt
   290     val thy = ProofContext.theory_of ctxt
   291     fun card (Type (@{type_name fun}, [T1, T2])) =
   291     fun card (Type (@{type_name fun}, [T1, T2])) =
   292         reasonable_power (card T2) (card T1)
   292         reasonable_power (card T2) (card T1)
   293       | card (Type (@{type_name "*"}, [T1, T2])) = card T1 * card T2
   293       | card (Type (@{type_name Product_Type.prod}, [T1, T2])) = card T1 * card T2
   294       | card @{typ bool} = 2
   294       | card @{typ bool} = 2
   295       | card T = Int.max (1, raw_card T)
   295       | card T = Int.max (1, raw_card T)
   296     val neg_t = @{const Not} $ Object_Logic.atomize_term thy t
   296     val neg_t = @{const Not} $ Object_Logic.atomize_term thy t
   297     val _ = fold_types (K o check_type ctxt) neg_t ()
   297     val _ = fold_types (K o check_type ctxt) neg_t ()
   298     val frees = Term.add_frees neg_t []
   298     val frees = Term.add_frees neg_t []