src/Pure/Isar/auto_bind.ML
changeset 59970 e9f73d87d904
parent 46219 426ed18eba43
child 60401 16cf5090d3a6
equal deleted inserted replaced
59969:bcccad156236 59970:e9f73d87d904
     7 signature AUTO_BIND =
     7 signature AUTO_BIND =
     8 sig
     8 sig
     9   val thesisN: string
     9   val thesisN: string
    10   val thisN: string
    10   val thisN: string
    11   val assmsN: string
    11   val assmsN: string
    12   val goal: theory -> term list -> (indexname * term option) list
    12   val goal: Proof.context -> term list -> (indexname * term option) list
    13   val facts: theory -> term list -> (indexname * term option) list
    13   val facts: Proof.context -> term list -> (indexname * term option) list
    14   val no_facts: (indexname * term option) list
    14   val no_facts: (indexname * term option) list
    15 end;
    15 end;
    16 
    16 
    17 structure Auto_Bind: AUTO_BIND =
    17 structure Auto_Bind: AUTO_BIND =
    18 struct
    18 struct
    21 
    21 
    22 val thesisN = "thesis";
    22 val thesisN = "thesis";
    23 val thisN = "this";
    23 val thisN = "this";
    24 val assmsN = "assms";
    24 val assmsN = "assms";
    25 
    25 
    26 fun strip_judgment thy = Object_Logic.drop_judgment thy o Logic.strip_assums_concl;
    26 fun strip_judgment ctxt = Object_Logic.drop_judgment ctxt o Logic.strip_assums_concl;
    27 
    27 
    28 fun statement_binds thy name prop =
    28 fun statement_binds ctxt name prop =
    29   [((name, 0), SOME (fold_rev Term.abs (Logic.strip_params prop) (strip_judgment thy prop)))];
    29   [((name, 0), SOME (fold_rev Term.abs (Logic.strip_params prop) (strip_judgment ctxt prop)))];
    30 
    30 
    31 
    31 
    32 (* goal *)
    32 (* goal *)
    33 
    33 
    34 fun goal thy [prop] = statement_binds thy thesisN prop
    34 fun goal ctxt [prop] = statement_binds ctxt thesisN prop
    35   | goal _ _ = [((thesisN, 0), NONE)];
    35   | goal _ _ = [((thesisN, 0), NONE)];
    36 
    36 
    37 
    37 
    38 (* facts *)
    38 (* facts *)
    39 
    39 
    40 fun get_arg thy prop =
    40 fun get_arg ctxt prop =
    41   (case strip_judgment thy prop of
    41   (case strip_judgment ctxt prop of
    42     _ $ t => SOME (fold_rev Term.abs (Logic.strip_params prop) t)
    42     _ $ t => SOME (fold_rev Term.abs (Logic.strip_params prop) t)
    43   | _ => NONE);
    43   | _ => NONE);
    44 
    44 
    45 fun facts _ [] = []
    45 fun facts _ [] = []
    46   | facts thy props =
    46   | facts ctxt props =
    47       let val prop = List.last props
    47       let val prop = List.last props
    48       in [(Syntax_Ext.dddot_indexname, get_arg thy prop)] @ statement_binds thy thisN prop end;
    48       in [(Syntax_Ext.dddot_indexname, get_arg ctxt prop)] @ statement_binds ctxt thisN prop end;
    49 
    49 
    50 val no_facts = [(Syntax_Ext.dddot_indexname, NONE), ((thisN, 0), NONE)];
    50 val no_facts = [(Syntax_Ext.dddot_indexname, NONE), ((thisN, 0), NONE)];
    51 
    51 
    52 end;
    52 end;