src/HOL/Tools/Sledgehammer/sledgehammer_reconstruct.ML
changeset 50017 d9c1b11a78d2
parent 50016 0ae5328ded8c
child 50018 4ea26c74d7ea
equal deleted inserted replaced
50016:0ae5328ded8c 50017:d9c1b11a78d2
   293   Prove of isar_qualifier list * label * term * byline
   293   Prove of isar_qualifier list * label * term * byline
   294 and byline =
   294 and byline =
   295   By_Metis of facts |
   295   By_Metis of facts |
   296   Case_Split of isar_step list list * facts
   296   Case_Split of isar_step list list * facts
   297 
   297 
       
   298 val assume_prefix = "a"
   298 val have_prefix = "f"
   299 val have_prefix = "f"
   299 val raw_prefix = "x"
   300 val raw_prefix = "x"
   300 
   301 
   301 fun raw_label_for_name (num, ss) =
   302 fun raw_label_for_name (num, ss) =
   302   case resolve_conjecture ss of
   303   case resolve_conjecture ss of
   704 fun prefix_for_depth n = replicate_string (n + 1)
   705 fun prefix_for_depth n = replicate_string (n + 1)
   705 
   706 
   706 val relabel_proof =
   707 val relabel_proof =
   707   let
   708   let
   708     fun aux _ _ _ [] = []
   709     fun aux _ _ _ [] = []
   709       | aux subst depth (next_assum, next_fact) (Assume (l, t) :: proof) =
   710       | aux subst depth (next_assum, next_have) (Assume (l, t) :: proof) =
   710         if l = no_label then
   711         if l = no_label then
   711           Assume (l, t) :: aux subst depth (next_assum, next_fact) proof
   712           Assume (l, t) :: aux subst depth (next_assum, next_have) proof
   712         else
   713         else
   713           let val l' = (prefix_for_depth depth have_prefix, next_assum) in
   714           let val l' = (prefix_for_depth depth assume_prefix, next_assum) in
   714             Assume (l', t) ::
   715             Assume (l', t) ::
   715             aux ((l, l') :: subst) depth (next_assum + 1, next_fact) proof
   716             aux ((l, l') :: subst) depth (next_assum + 1, next_have) proof
   716           end
   717           end
   717       | aux subst depth (next_assum, next_fact)
   718       | aux subst depth (next_assum, next_have)
   718             (Prove (qs, l, t, by) :: proof) =
   719             (Prove (qs, l, t, by) :: proof) =
   719         let
   720         let
   720           val (l', subst, next_fact) =
   721           val (l', subst, next_have) =
   721             if l = no_label then
   722             if l = no_label then
   722               (l, subst, next_fact)
   723               (l, subst, next_have)
   723             else
   724             else
   724               let
   725               let val l' = (prefix_for_depth depth have_prefix, next_have) in
   725                 val l' = (prefix_for_depth depth have_prefix, next_fact)
   726                 (l', (l, l') :: subst, next_have + 1)
   726               in (l', (l, l') :: subst, next_fact + 1) end
   727               end
   727           val relabel_facts =
   728           val relabel_facts =
   728             apfst (maps (the_list o AList.lookup (op =) subst))
   729             apfst (maps (the_list o AList.lookup (op =) subst))
   729           val by =
   730           val by =
   730             case by of
   731             case by of
   731               By_Metis facts => By_Metis (relabel_facts facts)
   732               By_Metis facts => By_Metis (relabel_facts facts)
   732             | Case_Split (proofs, facts) =>
   733             | Case_Split (proofs, facts) =>
   733               Case_Split (map (aux subst (depth + 1) (1, 1)) proofs,
   734               Case_Split (map (aux subst (depth + 1) (1, 1)) proofs,
   734                           relabel_facts facts)
   735                           relabel_facts facts)
   735         in
   736         in
   736           Prove (qs, l', t, by) :: aux subst depth (next_assum, next_fact) proof
   737           Prove (qs, l', t, by) :: aux subst depth (next_assum, next_have) proof
   737         end
   738         end
   738       | aux subst depth nextp (step :: proof) =
   739       | aux subst depth nextp (step :: proof) =
   739         step :: aux subst depth nextp proof
   740         step :: aux subst depth nextp proof
   740   in aux [] 0 (1, 1) end
   741   in aux [] 0 (1, 1) end
   741 
   742