ProgTutorial/Helper/Command/Command.thy
author Christian Urban <urbanc@in.tum.de>
Fri, 29 Oct 2010 11:00:37 +0100
changeset 451 fc074e669f9f
parent 449 f952f2679a11
child 514 7e25716c3744
permissions -rw-r--r--
disabled foobar_prove; updated to new Isabelle
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
319
6bce4acf7f2a added file for producing a keyword file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     1
theory Command
6bce4acf7f2a added file for producing a keyword file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     2
imports Main
6bce4acf7f2a added file for producing a keyword file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     3
begin
321
e450fa467e3f polished the commands section
Christian Urban <urbanc@in.tum.de>
parents: 319
diff changeset
     4
319
6bce4acf7f2a added file for producing a keyword file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
ML {*
6bce4acf7f2a added file for producing a keyword file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
let
449
f952f2679a11 updated to new isabelle
Christian Urban <urbanc@in.tum.de>
parents: 426
diff changeset
     7
   val do_nothing = Scan.succeed (Local_Theory.background_theory I)
426
d94755882e36 updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 422
diff changeset
     8
   val kind = Keyword.thy_decl
319
6bce4acf7f2a added file for producing a keyword file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     9
in
426
d94755882e36 updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 422
diff changeset
    10
   Outer_Syntax.local_theory "foobar" "description of foobar" kind do_nothing
319
6bce4acf7f2a added file for producing a keyword file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    11
end
6bce4acf7f2a added file for producing a keyword file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    12
*}
6bce4acf7f2a added file for producing a keyword file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    13
6bce4acf7f2a added file for producing a keyword file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    14
ML {*
6bce4acf7f2a added file for producing a keyword file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    15
let
321
e450fa467e3f polished the commands section
Christian Urban <urbanc@in.tum.de>
parents: 319
diff changeset
    16
  fun trace_prop str =
449
f952f2679a11 updated to new isabelle
Christian Urban <urbanc@in.tum.de>
parents: 426
diff changeset
    17
     Local_Theory.background_theory (fn lthy => (tracing str; lthy))
426
d94755882e36 updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 422
diff changeset
    18
  val trace_prop_parser = Parse.prop >> trace_prop
d94755882e36 updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 422
diff changeset
    19
  val kind = Keyword.thy_decl
321
e450fa467e3f polished the commands section
Christian Urban <urbanc@in.tum.de>
parents: 319
diff changeset
    20
in
426
d94755882e36 updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 422
diff changeset
    21
  Outer_Syntax.local_theory "foobar_trace" "traces a proposition"
321
e450fa467e3f polished the commands section
Christian Urban <urbanc@in.tum.de>
parents: 319
diff changeset
    22
    kind trace_prop_parser
e450fa467e3f polished the commands section
Christian Urban <urbanc@in.tum.de>
parents: 319
diff changeset
    23
end
e450fa467e3f polished the commands section
Christian Urban <urbanc@in.tum.de>
parents: 319
diff changeset
    24
*}
e450fa467e3f polished the commands section
Christian Urban <urbanc@in.tum.de>
parents: 319
diff changeset
    25
e450fa467e3f polished the commands section
Christian Urban <urbanc@in.tum.de>
parents: 319
diff changeset
    26
ML {*
e450fa467e3f polished the commands section
Christian Urban <urbanc@in.tum.de>
parents: 319
diff changeset
    27
let
e450fa467e3f polished the commands section
Christian Urban <urbanc@in.tum.de>
parents: 319
diff changeset
    28
   fun prove_prop str lthy =
e450fa467e3f polished the commands section
Christian Urban <urbanc@in.tum.de>
parents: 319
diff changeset
    29
     let
e450fa467e3f polished the commands section
Christian Urban <urbanc@in.tum.de>
parents: 319
diff changeset
    30
       val prop = Syntax.read_prop lthy str
e450fa467e3f polished the commands section
Christian Urban <urbanc@in.tum.de>
parents: 319
diff changeset
    31
     in
422
e79563b14b0f updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 394
diff changeset
    32
       Proof.theorem NONE (K I) [[(prop,[])]] lthy
321
e450fa467e3f polished the commands section
Christian Urban <urbanc@in.tum.de>
parents: 319
diff changeset
    33
     end;
426
d94755882e36 updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 422
diff changeset
    34
   val prove_prop_parser = Parse.prop >> prove_prop
d94755882e36 updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 422
diff changeset
    35
   val kind = Keyword.thy_goal
321
e450fa467e3f polished the commands section
Christian Urban <urbanc@in.tum.de>
parents: 319
diff changeset
    36
in
426
d94755882e36 updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 422
diff changeset
    37
   Outer_Syntax.local_theory_to_proof "foobar_goal" "proving a proposition"
321
e450fa467e3f polished the commands section
Christian Urban <urbanc@in.tum.de>
parents: 319
diff changeset
    38
     kind prove_prop_parser
e450fa467e3f polished the commands section
Christian Urban <urbanc@in.tum.de>
parents: 319
diff changeset
    39
end
e450fa467e3f polished the commands section
Christian Urban <urbanc@in.tum.de>
parents: 319
diff changeset
    40
*}
e450fa467e3f polished the commands section
Christian Urban <urbanc@in.tum.de>
parents: 319
diff changeset
    41
e450fa467e3f polished the commands section
Christian Urban <urbanc@in.tum.de>
parents: 319
diff changeset
    42
ML {*
451
fc074e669f9f disabled foobar_prove; updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 449
diff changeset
    43
structure Result = Proof_Data(
fc074e669f9f disabled foobar_prove; updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 449
diff changeset
    44
  type T = unit -> term
fc074e669f9f disabled foobar_prove; updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 449
diff changeset
    45
  fun init thy () = error "Result")
fc074e669f9f disabled foobar_prove; updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 449
diff changeset
    46
fc074e669f9f disabled foobar_prove; updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 449
diff changeset
    47
val result_cookie = (Result.get, Result.put, "Result.put")
321
e450fa467e3f polished the commands section
Christian Urban <urbanc@in.tum.de>
parents: 319
diff changeset
    48
*}
451
fc074e669f9f disabled foobar_prove; updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 449
diff changeset
    49
324
4172c0743cf2 updated foobar_proof example
Christian Urban <urbanc@in.tum.de>
parents: 321
diff changeset
    50
ML{*
321
e450fa467e3f polished the commands section
Christian Urban <urbanc@in.tum.de>
parents: 319
diff changeset
    51
let
324
4172c0743cf2 updated foobar_proof example
Christian Urban <urbanc@in.tum.de>
parents: 321
diff changeset
    52
   fun after_qed thm_name thms lthy =
394
0019ebf76e10 updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 328
diff changeset
    53
        Local_Theory.note (thm_name, (flat thms)) lthy |> snd
324
4172c0743cf2 updated foobar_proof example
Christian Urban <urbanc@in.tum.de>
parents: 321
diff changeset
    54
4172c0743cf2 updated foobar_proof example
Christian Urban <urbanc@in.tum.de>
parents: 321
diff changeset
    55
   fun setup_proof (thm_name, (txt, pos)) lthy =
321
e450fa467e3f polished the commands section
Christian Urban <urbanc@in.tum.de>
parents: 319
diff changeset
    56
   let
451
fc074e669f9f disabled foobar_prove; updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 449
diff changeset
    57
     val trm = Code_Runtime.value lthy result_cookie ("", txt)
321
e450fa467e3f polished the commands section
Christian Urban <urbanc@in.tum.de>
parents: 319
diff changeset
    58
   in
422
e79563b14b0f updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 394
diff changeset
    59
     Proof.theorem NONE (after_qed thm_name) [[(trm,[])]] lthy
324
4172c0743cf2 updated foobar_proof example
Christian Urban <urbanc@in.tum.de>
parents: 321
diff changeset
    60
   end
321
e450fa467e3f polished the commands section
Christian Urban <urbanc@in.tum.de>
parents: 319
diff changeset
    61
426
d94755882e36 updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 422
diff changeset
    62
   val parser = Parse_Spec.opt_thm_name ":" -- Parse.ML_source
324
4172c0743cf2 updated foobar_proof example
Christian Urban <urbanc@in.tum.de>
parents: 321
diff changeset
    63
 
321
e450fa467e3f polished the commands section
Christian Urban <urbanc@in.tum.de>
parents: 319
diff changeset
    64
in
426
d94755882e36 updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 422
diff changeset
    65
   Outer_Syntax.local_theory_to_proof "foobar_prove" "proving a proposition" 
d94755882e36 updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 422
diff changeset
    66
     Keyword.thy_goal (parser >> setup_proof)
324
4172c0743cf2 updated foobar_proof example
Christian Urban <urbanc@in.tum.de>
parents: 321
diff changeset
    67
end*}
4172c0743cf2 updated foobar_proof example
Christian Urban <urbanc@in.tum.de>
parents: 321
diff changeset
    68
321
e450fa467e3f polished the commands section
Christian Urban <urbanc@in.tum.de>
parents: 319
diff changeset
    69
319
6bce4acf7f2a added file for producing a keyword file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    70
451
fc074e669f9f disabled foobar_prove; updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 449
diff changeset
    71
319
6bce4acf7f2a added file for producing a keyword file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    72
end