src/HOL/Tools/Function/lexicographic_order.ML
changeset 60752 b48830b670a1
parent 60682 5a6cd2560549
child 60781 2da59cdf531c
equal deleted inserted replaced
60751:83f04804696c 60752:b48830b670a1
   102           | SOME order => SOME (col :: transform_order col order))
   102           | SOME order => SOME (col :: transform_order col order))
   103 
   103 
   104 
   104 
   105 (** Proof Reconstruction **)
   105 (** Proof Reconstruction **)
   106 
   106 
   107 fun prove_row (c :: cs) =
   107 fun prove_row_tac ctxt (c :: cs) =
   108   (case Lazy.force c of
   108       (case Lazy.force c of
   109      Less thm =>
   109         Less thm =>
   110        rtac @{thm "mlex_less"} 1
   110           resolve_tac ctxt @{thms mlex_less} 1
   111        THEN PRIMITIVE (Thm.elim_implies thm)
   111           THEN PRIMITIVE (Thm.elim_implies thm)
   112    | LessEq (thm, _) =>
   112       | LessEq (thm, _) =>
   113        rtac @{thm "mlex_leq"} 1
   113           resolve_tac ctxt @{thms mlex_leq} 1
   114        THEN PRIMITIVE (Thm.elim_implies thm)
   114           THEN PRIMITIVE (Thm.elim_implies thm)
   115        THEN prove_row cs
   115           THEN prove_row_tac ctxt cs
   116    | _ => raise General.Fail "lexicographic_order")
   116       | _ => raise General.Fail "lexicographic_order")
   117  | prove_row [] = no_tac;
   117   | prove_row_tac _ [] = no_tac;
   118 
   118 
   119 
   119 
   120 (** Error reporting **)
   120 (** Error reporting **)
   121 
   121 
   122 fun row_index i = chr (i + 97)  (* FIXME not scalable wrt. chr range *)
   122 fun row_index i = chr (i + 97)  (* FIXME not scalable wrt. chr range *)
   200             else ()
   200             else ()
   201   
   201   
   202         in (* 4: proof reconstruction *)
   202         in (* 4: proof reconstruction *)
   203           st |>
   203           st |>
   204           (PRIMITIVE (cterm_instantiate [apply2 (Thm.cterm_of ctxt) (rel, relation)])
   204           (PRIMITIVE (cterm_instantiate [apply2 (Thm.cterm_of ctxt) (rel, relation)])
   205             THEN (REPEAT (rtac @{thm "wf_mlex"} 1))
   205             THEN (REPEAT (resolve_tac ctxt @{thms wf_mlex} 1))
   206             THEN (rtac @{thm "wf_empty"} 1)
   206             THEN (resolve_tac ctxt @{thms wf_empty} 1)
   207             THEN EVERY (map prove_row clean_table))
   207             THEN EVERY (map (prove_row_tac ctxt) clean_table))
   208         end
   208         end
   209   end) 1 st;
   209   end) 1 st;
   210 
   210 
   211 fun lexicographic_order_tac quiet ctxt =
   211 fun lexicographic_order_tac quiet ctxt =
   212   TRY (Function_Common.termination_rule_tac ctxt 1) THEN
   212   TRY (Function_Common.termination_rule_tac ctxt 1) THEN