1 (* Title: Provers/project_rule.ML
6 HH ==> (x1:A1 --> P1 x1) & ... & (xn:An --> Pn xn)
11 signature PROJECT_RULE_DATA =
18 signature PROJECT_RULE =
20 val project: Proof.context -> int -> thm -> thm
21 val projects: Proof.context -> int list -> thm -> thm list
22 val projections: Proof.context -> thm -> thm list
25 functor ProjectRuleFun(Data: PROJECT_RULE_DATA): PROJECT_RULE =
28 fun conj1 th = th RS Data.conjunct1;
29 fun conj2 th = th RS Data.conjunct2;
30 fun imp th = th RS Data.mp;
32 fun projects ctxt is raw_rule =
34 fun proj 1 th = the_default th (try conj1 th)
35 | proj k th = proj (k - 1) (conj2 th);
39 | SOME th' => prems (k + 1) th');
40 val ((_, [rule]), ctxt') = Variable.import_thms true [raw_rule] ctxt;
44 |> prems 0 |-> (fn k =>
45 Thm.permute_prems 0 (~ k)
46 #> singleton (Variable.export ctxt' ctxt)
47 #> Drule.zero_var_indexes
48 #> RuleCases.save raw_rule
49 #> RuleCases.add_consumes k);
52 fun project ctxt i th = hd (projects ctxt [i] th);
54 fun projections ctxt raw_rule =
59 | SOME th' => projs (k + 1) th');
60 val ((_, [rule]), _) = Variable.import_thms true [raw_rule] ctxt;
61 in projects ctxt (1 upto projs 1 rule) raw_rule end;