src/Pure/Isar/auto_bind.ML
author blanchet
Fri, 01 Aug 2014 14:43:57 +0200
changeset 57743 0af2d5dfb0ac
parent 46219 426ed18eba43
child 59970 e9f73d87d904
permissions -rw-r--r--
pushing skolems under 'iff' sometimes breaks things further down the proof (as was to be feared)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6783
9cf9c17d9e35 renamed object_logic.ML to Isar/auto_bind.ML and tuned this module;
wenzelm
parents:
diff changeset
     1
(*  Title:      Pure/Isar/auto_bind.ML
9cf9c17d9e35 renamed object_logic.ML to Isar/auto_bind.ML and tuned this module;
wenzelm
parents:
diff changeset
     2
    Author:     Markus Wenzel, TU Muenchen
9cf9c17d9e35 renamed object_logic.ML to Isar/auto_bind.ML and tuned this module;
wenzelm
parents:
diff changeset
     3
17349
03fafcdfdfa7 added cases, rule_contextN;
wenzelm
parents: 15531
diff changeset
     4
Automatic bindings of Isar text elements.
6783
9cf9c17d9e35 renamed object_logic.ML to Isar/auto_bind.ML and tuned this module;
wenzelm
parents:
diff changeset
     5
*)
9cf9c17d9e35 renamed object_logic.ML to Isar/auto_bind.ML and tuned this module;
wenzelm
parents:
diff changeset
     6
9cf9c17d9e35 renamed object_logic.ML to Isar/auto_bind.ML and tuned this module;
wenzelm
parents:
diff changeset
     7
signature AUTO_BIND =
9cf9c17d9e35 renamed object_logic.ML to Isar/auto_bind.ML and tuned this module;
wenzelm
parents:
diff changeset
     8
sig
9296
0d2b31e1ea1b export thesisN separately;
wenzelm
parents: 8807
diff changeset
     9
  val thesisN: string
17349
03fafcdfdfa7 added cases, rule_contextN;
wenzelm
parents: 15531
diff changeset
    10
  val thisN: string
21448
09c953c07008 added assmsN;
wenzelm
parents: 19075
diff changeset
    11
  val assmsN: string
17349
03fafcdfdfa7 added cases, rule_contextN;
wenzelm
parents: 15531
diff changeset
    12
  val goal: theory -> term list -> (indexname * term option) list
03fafcdfdfa7 added cases, rule_contextN;
wenzelm
parents: 15531
diff changeset
    13
  val facts: theory -> term list -> (indexname * term option) list
17852
a06b185a26d7 added no_facts;
wenzelm
parents: 17349
diff changeset
    14
  val no_facts: (indexname * term option) list
6783
9cf9c17d9e35 renamed object_logic.ML to Isar/auto_bind.ML and tuned this module;
wenzelm
parents:
diff changeset
    15
end;
9cf9c17d9e35 renamed object_logic.ML to Isar/auto_bind.ML and tuned this module;
wenzelm
parents:
diff changeset
    16
33386
ff29d1549aca modernized structure AutoBind;
wenzelm
parents: 29606
diff changeset
    17
structure Auto_Bind: AUTO_BIND =
6783
9cf9c17d9e35 renamed object_logic.ML to Isar/auto_bind.ML and tuned this module;
wenzelm
parents:
diff changeset
    18
struct
9cf9c17d9e35 renamed object_logic.ML to Isar/auto_bind.ML and tuned this module;
wenzelm
parents:
diff changeset
    19
10359
445e3b87f28b improved statement bindings for props;
wenzelm
parents: 9464
diff changeset
    20
(** bindings **)
445e3b87f28b improved statement bindings for props;
wenzelm
parents: 9464
diff changeset
    21
445e3b87f28b improved statement bindings for props;
wenzelm
parents: 9464
diff changeset
    22
val thesisN = "thesis";
445e3b87f28b improved statement bindings for props;
wenzelm
parents: 9464
diff changeset
    23
val thisN = "this";
21448
09c953c07008 added assmsN;
wenzelm
parents: 19075
diff changeset
    24
val assmsN = "assms";
10359
445e3b87f28b improved statement bindings for props;
wenzelm
parents: 9464
diff changeset
    25
35625
9c818cab0dd0 modernized structure Object_Logic;
wenzelm
parents: 33386
diff changeset
    26
fun strip_judgment thy = Object_Logic.drop_judgment thy o Logic.strip_assums_concl;
11764
fd780dd6e0b4 use ObjectLogic;
wenzelm
parents: 10808
diff changeset
    27
17349
03fafcdfdfa7 added cases, rule_contextN;
wenzelm
parents: 15531
diff changeset
    28
fun statement_binds thy name prop =
46219
426ed18eba43 discontinued old-style Term.list_abs in favour of plain Term.abs;
wenzelm
parents: 42288
diff changeset
    29
  [((name, 0), SOME (fold_rev Term.abs (Logic.strip_params prop) (strip_judgment thy prop)))];
10359
445e3b87f28b improved statement bindings for props;
wenzelm
parents: 9464
diff changeset
    30
445e3b87f28b improved statement bindings for props;
wenzelm
parents: 9464
diff changeset
    31
445e3b87f28b improved statement bindings for props;
wenzelm
parents: 9464
diff changeset
    32
(* goal *)
445e3b87f28b improved statement bindings for props;
wenzelm
parents: 9464
diff changeset
    33
17349
03fafcdfdfa7 added cases, rule_contextN;
wenzelm
parents: 15531
diff changeset
    34
fun goal thy [prop] = statement_binds thy thesisN prop
15531
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 14981
diff changeset
    35
  | goal _ _ = [((thesisN, 0), NONE)];
10359
445e3b87f28b improved statement bindings for props;
wenzelm
parents: 9464
diff changeset
    36
445e3b87f28b improved statement bindings for props;
wenzelm
parents: 9464
diff changeset
    37
445e3b87f28b improved statement bindings for props;
wenzelm
parents: 9464
diff changeset
    38
(* facts *)
445e3b87f28b improved statement bindings for props;
wenzelm
parents: 9464
diff changeset
    39
17349
03fafcdfdfa7 added cases, rule_contextN;
wenzelm
parents: 15531
diff changeset
    40
fun get_arg thy prop =
03fafcdfdfa7 added cases, rule_contextN;
wenzelm
parents: 15531
diff changeset
    41
  (case strip_judgment thy prop of
46219
426ed18eba43 discontinued old-style Term.list_abs in favour of plain Term.abs;
wenzelm
parents: 42288
diff changeset
    42
    _ $ t => SOME (fold_rev Term.abs (Logic.strip_params prop) t)
15531
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 14981
diff changeset
    43
  | _ => NONE);
10359
445e3b87f28b improved statement bindings for props;
wenzelm
parents: 9464
diff changeset
    44
12140
a987beab002d facts: multiple args;
wenzelm
parents: 11764
diff changeset
    45
fun facts _ [] = []
17349
03fafcdfdfa7 added cases, rule_contextN;
wenzelm
parents: 15531
diff changeset
    46
  | facts thy props =
41489
8e2b8649507d standardized split_last/last_elem towards List.last;
wenzelm
parents: 35625
diff changeset
    47
      let val prop = List.last props
42288
2074b31650e6 discontinued special treatment of structure Syntax_Ext (formerly Syn_Ext);
wenzelm
parents: 41489
diff changeset
    48
      in [(Syntax_Ext.dddot_indexname, get_arg thy prop)] @ statement_binds thy thisN prop end;
10359
445e3b87f28b improved statement bindings for props;
wenzelm
parents: 9464
diff changeset
    49
42288
2074b31650e6 discontinued special treatment of structure Syntax_Ext (formerly Syn_Ext);
wenzelm
parents: 41489
diff changeset
    50
val no_facts = [(Syntax_Ext.dddot_indexname, NONE), ((thisN, 0), NONE)];
10808
cc4a3ed7e70b added drop_judgment;
wenzelm
parents: 10377
diff changeset
    51
6783
9cf9c17d9e35 renamed object_logic.ML to Isar/auto_bind.ML and tuned this module;
wenzelm
parents:
diff changeset
    52
end;