1 (* Title: FOL/ex/IffOracle.thy
3 Author: Lawrence C Paulson, Cambridge University Computer Laboratory
4 Copyright 1996 University of Cambridge
7 header {* Example of Declaring an Oracle *}
13 subsection {* Oracle declaration *}
16 This oracle makes tautologies of the form @{text "P <-> P <-> P <-> P"}.
17 The length is specified by an integer, which is checked to be even
21 oracle iff_oracle (int) = {*
23 fun mk_iff 1 = Var (("P", 0), @{typ o})
24 | mk_iff n = FOLogic.iff $ Var (("P", 0), @{typ o}) $ mk_iff (n - 1);
27 if n > 0 andalso n mod 2 = 0
28 then FOLogic.mk_Trueprop (mk_iff n)
29 else raise Fail ("iff_oracle: " ^ string_of_int n)
34 subsection {* Oracle as low-level rule *}
36 ML {* iff_oracle @{theory} 2 *}
37 ML {* iff_oracle @{theory} 10 *}
39 text {* These oracle calls had better fail. *}
42 (iff_oracle @{theory} 5; error "?")
43 handle Fail _ => warning "Oracle failed, as expected"
47 (iff_oracle @{theory} 1; error "?")
48 handle Fail _ => warning "Oracle failed, as expected"
52 subsection {* Oracle as proof method *}
55 Method.simple_args Args.nat (fn n => fn ctxt =>
57 (HEADGOAL (Tactic.rtac (iff_oracle (ProofContext.theory_of ctxt) n))
58 handle Fail _ => no_tac))
65 lemma "A <-> A <-> A <-> A <-> A <-> A <-> A <-> A <-> A <-> A"
68 lemma "A <-> A <-> A <-> A <-> A"