src/Pure/Isar/auto_bind.ML
changeset 60408 1fd46ced2fa8
parent 60401 16cf5090d3a6
child 60414 f25f2f2ba48c
equal deleted inserted replaced
60407:53ef7b78e78a 60408:1fd46ced2fa8
     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 abs_params: term -> term -> term
    12   val goal: Proof.context -> term list -> (indexname * term option) list
    13   val goal: Proof.context -> term list -> (indexname * term option) list
    13   val facts: Proof.context -> term list -> (indexname * term option) list
    14   val facts: Proof.context -> term list -> (indexname * term option) list
    14   val no_facts: indexname list
    15   val no_facts: indexname list
    15 end;
    16 end;
    16 
    17 
    23 val thisN = "this";
    24 val thisN = "this";
    24 val assmsN = "assms";
    25 val assmsN = "assms";
    25 
    26 
    26 fun strip_judgment ctxt = Object_Logic.drop_judgment ctxt o Logic.strip_assums_concl;
    27 fun strip_judgment ctxt = Object_Logic.drop_judgment ctxt o Logic.strip_assums_concl;
    27 
    28 
       
    29 fun abs_params prop = fold_rev Term.abs (Logic.strip_params prop);
       
    30 
    28 fun statement_binds ctxt name prop =
    31 fun statement_binds ctxt name prop =
    29   [((name, 0), SOME (fold_rev Term.abs (Logic.strip_params prop) (strip_judgment ctxt prop)))];
    32   [((name, 0), SOME (abs_params prop (strip_judgment ctxt prop)))];
    30 
    33 
    31 
    34 
    32 (* goal *)
    35 (* goal *)
    33 
    36 
    34 fun goal ctxt [prop] = statement_binds ctxt thesisN prop
    37 fun goal ctxt [prop] = statement_binds ctxt thesisN prop
    37 
    40 
    38 (* facts *)
    41 (* facts *)
    39 
    42 
    40 fun get_arg ctxt prop =
    43 fun get_arg ctxt prop =
    41   (case strip_judgment ctxt prop of
    44   (case strip_judgment ctxt prop of
    42     _ $ t => SOME (fold_rev Term.abs (Logic.strip_params prop) t)
    45     _ $ t => SOME (abs_params prop t)
    43   | _ => NONE);
    46   | _ => NONE);
    44 
    47 
    45 fun facts _ [] = []
    48 fun facts ctxt props =
    46   | facts ctxt props =
    49   (case try List.last props of
    47       let val prop = List.last props
    50     NONE => []
    48       in [(Syntax_Ext.dddot_indexname, get_arg ctxt prop)] @ statement_binds ctxt thisN prop end;
    51   | SOME prop =>
       
    52       [(Syntax_Ext.dddot_indexname, get_arg ctxt prop)] @ statement_binds ctxt thisN prop);
    49 
    53 
    50 val no_facts = [Syntax_Ext.dddot_indexname, (thisN, 0)];
    54 val no_facts = [Syntax_Ext.dddot_indexname, (thisN, 0)];
    51 
    55 
    52 end;
    56 end;