src/HOL/TPTP/TPTP_Proof_Reconstruction.thy
changeset 58412 f65f11f4854c
parent 58411 e3d0354d2129
child 58941 f09dd46352ba
equal deleted inserted replaced
58411:e3d0354d2129 58412:f65f11f4854c
   773       if null gls then
   773       if null gls then
   774         raise NO_GOALS
   774         raise NO_GOALS
   775       else
   775       else
   776         map (strip_top_all_vars [] #> snd #> Logic.strip_horn #> snd) gls
   776         map (strip_top_all_vars [] #> snd #> Logic.strip_horn #> snd) gls
   777         (*Remove skolem-definition conclusion, to avoid wasting time analysing it*)
   777         (*Remove skolem-definition conclusion, to avoid wasting time analysing it*)
   778         |> List.filter (try_dest_Trueprop #> conc_is_skolem_def #> not)
   778         |> filter (try_dest_Trueprop #> conc_is_skolem_def #> not)
   779         (*There should only be a single goal*) (*FIXME this might not always be the case, in practice*)
   779         (*There should only be a single goal*) (*FIXME this might not always be the case, in practice*)
   780         (* |> tap (fn x => @{assert} (is_some (try the_single x))) *)
   780         (* |> tap (fn x => @{assert} (is_some (try the_single x))) *)
   781 
   781 
   782     (*look for subterms headed by a skolem constant, and whose
   782     (*look for subterms headed by a skolem constant, and whose
   783       arguments are all parameter Vars*)
   783       arguments are all parameter Vars*)
   829             (*the parameters we will concern ourselves with*)
   829             (*the parameters we will concern ourselves with*)
   830             val params' =
   830             val params' =
   831               Term.add_frees lhs []
   831               Term.add_frees lhs []
   832               |> distinct (op =)
   832               |> distinct (op =)
   833             (*check to make sure that params' <= params*)
   833             (*check to make sure that params' <= params*)
   834             val _ = @{assert} (List.all (member (op =) params) params')
   834             val _ = @{assert} (forall (member (op =) params) params')
   835             val skolem_const_ty =
   835             val skolem_const_ty =
   836               let
   836               let
   837                 val (skolem_const_prety, no_params) =
   837                 val (skolem_const_prety, no_params) =
   838                   Term.strip_comb lhs
   838                   Term.strip_comb lhs
   839                   |> apfst (dest_Var #> snd) (*head of lhs consists of a logical variable. we just want its type.*)
   839                   |> apfst (dest_Var #> snd) (*head of lhs consists of a logical variable. we just want its type.*)
  1405       case el of
  1405       case el of
  1406           InnerLoopOnce l'' => SOME l''
  1406           InnerLoopOnce l'' => SOME l''
  1407         | _ => NONE
  1407         | _ => NONE
  1408 
  1408 
  1409     fun check_sublist sought_sublist opt_list =
  1409     fun check_sublist sought_sublist opt_list =
  1410       if List.all is_none opt_list then false
  1410       if forall is_none opt_list then false
  1411       else
  1411       else
  1412         fold_options opt_list
  1412         fold_options opt_list
  1413         |> flat
  1413         |> flat
  1414         |> pair sought_sublist
  1414         |> pair sought_sublist
  1415         |> subset (op =)
  1415         |> subset (op =)
  1425           map sublist_of_loop_once l
  1425           map sublist_of_loop_once l
  1426           |> check_sublist l'
  1426           |> check_sublist l'
  1427       | InnerLoopOnce l' =>
  1427       | InnerLoopOnce l' =>
  1428           map sublist_of_inner_loop_once l
  1428           map sublist_of_inner_loop_once l
  1429           |> check_sublist l'
  1429           |> check_sublist l'
  1430       | _ => List.exists (curry (op =) x) l
  1430       | _ => exists (curry (op =) x) l
  1431   end;
  1431   end;
  1432 
  1432 
  1433 fun loop_can_feature loop_feats l =
  1433 fun loop_can_feature loop_feats l =
  1434   can_feature (Loop loop_feats) l orelse
  1434   can_feature (Loop loop_feats) l orelse
  1435   can_feature (LoopOnce loop_feats) l orelse
  1435   can_feature (LoopOnce loop_feats) l orelse
  2067           in
  2067           in
  2068             if is_none (source_inf_opt node) then []
  2068             if is_none (source_inf_opt node) then []
  2069             else
  2069             else
  2070               case the (source_inf_opt node) of
  2070               case the (source_inf_opt node) of
  2071                   TPTP_Proof.Inference (_, _, parent_inf) =>
  2071                   TPTP_Proof.Inference (_, _, parent_inf) =>
  2072                     List.map TPTP_Proof.parent_name parent_inf
  2072                     map TPTP_Proof.parent_name parent_inf
  2073                     |> List.filter (node_is_of_role role)
  2073                     |> filter (node_is_of_role role)
  2074                     |> (*FIXME currently definitions are not
  2074                     |> (*FIXME currently definitions are not
  2075                          included in the proof annotations, so
  2075                          included in the proof annotations, so
  2076                          i'm using all the definitions available
  2076                          i'm using all the definitions available
  2077                          in the proof. ideally i should only
  2077                          in the proof. ideally i should only
  2078                          use the ones in the proof annotation.*)
  2078                          use the ones in the proof annotation.*)