src/HOL/Tools/inductive_realizer.ML
changeset 56245 84fc7dfa3cd4
parent 55958 4ec984df4f45
child 56254 a2dd9200854d
equal deleted inserted replaced
56244:3298b7a2795a 56245:84fc7dfa3cd4
    29       let val ys = subsets xs
    29       let val ys = subsets xs
    30       in ys @ map (cons x) ys end;
    30       in ys @ map (cons x) ys end;
    31 
    31 
    32 val pred_of = fst o dest_Const o head_of;
    32 val pred_of = fst o dest_Const o head_of;
    33 
    33 
    34 fun strip_all' used names (Const ("all", _) $ Abs (s, T, t)) =
    34 fun strip_all' used names (Const (@{const_name Pure.all}, _) $ Abs (s, T, t)) =
    35       let val (s', names') = (case names of
    35       let val (s', names') = (case names of
    36           [] => (singleton (Name.variant_list used) s, [])
    36           [] => (singleton (Name.variant_list used) s, [])
    37         | name :: names' => (name, names'))
    37         | name :: names' => (name, names'))
    38       in strip_all' (s'::used) names' (subst_bound (Free (s', T), t)) end
    38       in strip_all' (s'::used) names' (subst_bound (Free (s', T), t)) end
    39   | strip_all' used names ((t as Const ("==>", _) $ P) $ Q) =
    39   | strip_all' used names ((t as Const (@{const_name Pure.imp}, _) $ P) $ Q) =
    40       t $ strip_all' used names Q
    40       t $ strip_all' used names Q
    41   | strip_all' _ _ t = t;
    41   | strip_all' _ _ t = t;
    42 
    42 
    43 fun strip_all t = strip_all' (Term.add_free_names t []) [] t;
    43 fun strip_all t = strip_all' (Term.add_free_names t []) [] t;
    44 
    44 
    45 fun strip_one name (Const ("all", _) $ Abs (s, T, Const ("==>", _) $ P $ Q)) =
    45 fun strip_one name
       
    46     (Const (@{const_name Pure.all}, _) $ Abs (s, T, Const (@{const_name Pure.imp}, _) $ P $ Q)) =
    46       (subst_bound (Free (name, T), P), subst_bound (Free (name, T), Q))
    47       (subst_bound (Free (name, T), P), subst_bound (Free (name, T), Q))
    47   | strip_one _ (Const ("==>", _) $ P $ Q) = (P, Q);
    48   | strip_one _ (Const (@{const_name Pure.imp}, _) $ P $ Q) = (P, Q);
    48 
    49 
    49 fun relevant_vars prop = fold (fn ((a, i), T) => fn vs =>
    50 fun relevant_vars prop = fold (fn ((a, i), T) => fn vs =>
    50      (case strip_type T of
    51      (case strip_type T of
    51         (_, Type (s, _)) => if s = @{type_name bool} then (a, T) :: vs else vs
    52         (_, Type (s, _)) => if s = @{type_name bool} then (a, T) :: vs else vs
    52       | _ => vs)) (Term.add_vars prop []) [];
    53       | _ => vs)) (Term.add_vars prop []) [];
   143     val conclT = Extraction.etype_of thy vs [] (Logic.strip_imp_concl rule');
   144     val conclT = Extraction.etype_of thy vs [] (Logic.strip_imp_concl rule');
   144     val used = map (fst o dest_Free) args;
   145     val used = map (fst o dest_Free) args;
   145 
   146 
   146     val is_rec = exists_Const (fn (c, _) => member (op =) rsets c);
   147     val is_rec = exists_Const (fn (c, _) => member (op =) rsets c);
   147 
   148 
   148     fun is_meta (Const ("all", _) $ Abs (s, _, P)) = is_meta P
   149     fun is_meta (Const (@{const_name Pure.all}, _) $ Abs (s, _, P)) = is_meta P
   149       | is_meta (Const ("==>", _) $ _ $ Q) = is_meta Q
   150       | is_meta (Const (@{const_name Pure.imp}, _) $ _ $ Q) = is_meta Q
   150       | is_meta (Const (@{const_name Trueprop}, _) $ t) =
   151       | is_meta (Const (@{const_name Trueprop}, _) $ t) =
   151           (case head_of t of
   152           (case head_of t of
   152             Const (s, _) => can (Inductive.the_inductive ctxt) s
   153             Const (s, _) => can (Inductive.the_inductive ctxt) s
   153           | _ => true)
   154           | _ => true)
   154       | is_meta _ = false;
   155       | is_meta _ = false;