src/Pure/Pure.thy
author wenzelm
Mon Jun 24 17:17:17 2013 +0200 (2013-06-24)
changeset 52438 7b5a5116f3af
parent 52437 c88354589b43
child 52439 4cf3f6153eb8
permissions -rw-r--r--
back to keyword 'pr' :: diag as required for ProofGeneral command line -- reject this TTY command in Isabelle/jEdit by other means;
wenzelm@48929
     1
(*  Title:      Pure/Pure.thy
wenzelm@48929
     2
    Author:     Makarius
wenzelm@48929
     3
wenzelm@48929
     4
Final stage of bootstrapping Pure, based on implicit background theory.
wenzelm@48929
     5
*)
wenzelm@48929
     6
wenzelm@48638
     7
theory Pure
wenzelm@48641
     8
  keywords
wenzelm@48641
     9
    "!!" "!" "%" "(" ")" "+" "," "--" ":" "::" ";" "<" "<=" "=" "=="
wenzelm@48641
    10
    "=>" "?" "[" "\<equiv>" "\<leftharpoondown>" "\<rightharpoonup>"
wenzelm@52143
    11
    "\<rightleftharpoons>" "\<subseteq>" "]" "and" "assumes"
wenzelm@48641
    12
    "attach" "begin" "binder" "constrains" "defines" "fixes" "for"
wenzelm@48641
    13
    "identifier" "if" "imports" "in" "includes" "infix" "infixl"
wenzelm@48641
    14
    "infixr" "is" "keywords" "notes" "obtains" "open" "output"
wenzelm@51293
    15
    "overloaded" "pervasive" "shows" "structure" "unchecked" "where" "|"
wenzelm@48641
    16
  and "header" :: diag
wenzelm@48641
    17
  and "chapter" :: thy_heading1
wenzelm@48641
    18
  and "section" :: thy_heading2
wenzelm@48641
    19
  and "subsection" :: thy_heading3
wenzelm@48641
    20
  and "subsubsection" :: thy_heading4
wenzelm@48641
    21
  and "text" "text_raw" :: thy_decl
wenzelm@48641
    22
  and "sect" :: prf_heading2 % "proof"
wenzelm@48641
    23
  and "subsect" :: prf_heading3 % "proof"
wenzelm@48641
    24
  and "subsubsect" :: prf_heading4 % "proof"
wenzelm@48641
    25
  and "txt" "txt_raw" :: prf_decl % "proof"
wenzelm@48641
    26
  and "classes" "classrel" "default_sort" "typedecl" "type_synonym"
wenzelm@48641
    27
    "nonterminal" "arities" "judgment" "consts" "syntax" "no_syntax"
wenzelm@51313
    28
    "translations" "no_translations" "defs" "definition"
wenzelm@48641
    29
    "abbreviation" "type_notation" "no_type_notation" "notation"
wenzelm@48641
    30
    "no_notation" "axiomatization" "theorems" "lemmas" "declare"
wenzelm@48641
    31
    "hide_class" "hide_type" "hide_const" "hide_fact" :: thy_decl
wenzelm@51295
    32
  and "ML" :: thy_decl % "ML"
wenzelm@48641
    33
  and "ML_prf" :: prf_decl % "proof"  (* FIXME % "ML" ?? *)
wenzelm@48641
    34
  and "ML_val" "ML_command" :: diag % "ML"
wenzelm@48641
    35
  and "setup" "local_setup" "attribute_setup" "method_setup"
wenzelm@48641
    36
    "declaration" "syntax_declaration" "simproc_setup"
wenzelm@48641
    37
    "parse_ast_translation" "parse_translation" "print_translation"
wenzelm@48641
    38
    "typed_print_translation" "print_ast_translation" "oracle" :: thy_decl % "ML"
wenzelm@48641
    39
  and "bundle" :: thy_decl
wenzelm@48641
    40
  and "include" "including" :: prf_decl
wenzelm@48641
    41
  and "print_bundles" :: diag
wenzelm@48641
    42
  and "context" "locale" :: thy_decl
wenzelm@51224
    43
  and "sublocale" "interpretation" :: thy_goal
wenzelm@51224
    44
  and "interpret" :: prf_goal % "proof"
wenzelm@48641
    45
  and "class" :: thy_decl
wenzelm@48641
    46
  and "subclass" :: thy_goal
wenzelm@48641
    47
  and "instantiation" :: thy_decl
wenzelm@48641
    48
  and "instance" :: thy_goal
wenzelm@48641
    49
  and "overloading" :: thy_decl
wenzelm@48641
    50
  and "code_datatype" :: thy_decl
wenzelm@48641
    51
  and "theorem" "lemma" "corollary" :: thy_goal
wenzelm@51274
    52
  and "schematic_theorem" "schematic_lemma" "schematic_corollary" :: thy_goal
wenzelm@48641
    53
  and "notepad" :: thy_decl
wenzelm@50128
    54
  and "have" :: prf_goal % "proof"
wenzelm@50128
    55
  and "hence" :: prf_goal % "proof" == "then have"
wenzelm@50128
    56
  and "show" :: prf_asm_goal % "proof"
wenzelm@50128
    57
  and "thus" :: prf_asm_goal % "proof" == "then show"
wenzelm@48641
    58
  and "then" "from" "with" :: prf_chain % "proof"
wenzelm@48641
    59
  and "note" "using" "unfolding" :: prf_decl % "proof"
wenzelm@48641
    60
  and "fix" "assume" "presume" "def" :: prf_asm % "proof"
wenzelm@48641
    61
  and "obtain" "guess" :: prf_asm_goal % "proof"
wenzelm@48641
    62
  and "let" "write" :: prf_decl % "proof"
wenzelm@48641
    63
  and "case" :: prf_asm % "proof"
wenzelm@48641
    64
  and "{" :: prf_open % "proof"
wenzelm@48641
    65
  and "}" :: prf_close % "proof"
wenzelm@48641
    66
  and "next" :: prf_block % "proof"
wenzelm@48641
    67
  and "qed" :: qed_block % "proof"
wenzelm@48641
    68
  and "by" ".." "." "done" "sorry" :: "qed" % "proof"
wenzelm@48641
    69
  and "oops" :: qed_global % "proof"
wenzelm@50128
    70
  and "defer" "prefer" "apply" :: prf_script % "proof"
wenzelm@50128
    71
  and "apply_end" :: prf_script % "proof" == ""
wenzelm@48641
    72
  and "proof" :: prf_block % "proof"
wenzelm@48641
    73
  and "also" "moreover" :: prf_decl % "proof"
wenzelm@48641
    74
  and "finally" "ultimately" :: prf_chain % "proof"
wenzelm@48641
    75
  and "back" :: prf_script % "proof"
wenzelm@48641
    76
  and "Isabelle.command" :: control
wenzelm@52060
    77
  and "help" "print_commands" "print_options"
wenzelm@51585
    78
    "print_context" "print_theory" "print_syntax" "print_abbrevs" "print_defn_rules"
wenzelm@48641
    79
    "print_theorems" "print_locales" "print_classes" "print_locale"
wenzelm@48641
    80
    "print_interps" "print_dependencies" "print_attributes"
wenzelm@48641
    81
    "print_simpset" "print_rules" "print_trans_rules" "print_methods"
wenzelm@49569
    82
    "print_antiquotations" "thy_deps" "locale_deps" "class_deps" "thm_deps"
wenzelm@48641
    83
    "print_binds" "print_facts" "print_cases" "print_statement" "thm"
wenzelm@48641
    84
    "prf" "full_prf" "prop" "term" "typ" "print_codesetup" "unused_thms"
wenzelm@48641
    85
    :: diag
wenzelm@48641
    86
  and "cd" :: control
wenzelm@48641
    87
  and "pwd" :: diag
wenzelm@48641
    88
  and "use_thy" "remove_thy" "kill_thy" :: control
wenzelm@52438
    89
  and "display_drafts" "print_drafts" "print_state" "pr" :: diag
wenzelm@52438
    90
  and "pretty_setmargin" "disable_pr" "enable_pr" "commit" "quit" "exit" :: control
wenzelm@48646
    91
  and "welcome" :: diag
wenzelm@48646
    92
  and "init_toplevel" "linear_undo" "undo" "undos_proof" "cannot_undo" "kill" :: control
wenzelm@48641
    93
  and "end" :: thy_end % "theory"
wenzelm@48646
    94
  and "realizers" "realizability" "extract_type" "extract" :: thy_decl
wenzelm@48646
    95
  and "find_theorems" "find_consts" :: diag
wenzelm@52437
    96
  and "ProofGeneral.process_pgip" "ProofGeneral.pr" "ProofGeneral.undo"
wenzelm@52437
    97
    "ProofGeneral.restart" "ProofGeneral.kill_proof" "ProofGeneral.inform_file_processed"
wenzelm@52437
    98
    "ProofGeneral.inform_file_retracted" :: control
wenzelm@48638
    99
begin
wenzelm@15803
   100
wenzelm@48891
   101
ML_file "Isar/isar_syn.ML"
wenzelm@48891
   102
ML_file "Tools/find_theorems.ML"
wenzelm@48891
   103
ML_file "Tools/find_consts.ML"
wenzelm@52009
   104
ML_file "Tools/proof_general_pure.ML"
wenzelm@48891
   105
wenzelm@48891
   106
wenzelm@26435
   107
section {* Further content for the Pure theory *}
wenzelm@20627
   108
wenzelm@18466
   109
subsection {* Meta-level connectives in assumptions *}
wenzelm@15803
   110
wenzelm@15803
   111
lemma meta_mp:
wenzelm@18019
   112
  assumes "PROP P ==> PROP Q" and "PROP P"
wenzelm@15803
   113
  shows "PROP Q"
wenzelm@18019
   114
    by (rule `PROP P ==> PROP Q` [OF `PROP P`])
wenzelm@15803
   115
nipkow@23432
   116
lemmas meta_impE = meta_mp [elim_format]
nipkow@23432
   117
wenzelm@15803
   118
lemma meta_spec:
wenzelm@26958
   119
  assumes "!!x. PROP P x"
wenzelm@26958
   120
  shows "PROP P x"
wenzelm@26958
   121
    by (rule `!!x. PROP P x`)
wenzelm@15803
   122
wenzelm@15803
   123
lemmas meta_allE = meta_spec [elim_format]
wenzelm@15803
   124
wenzelm@26570
   125
lemma swap_params:
wenzelm@26958
   126
  "(!!x y. PROP P x y) == (!!y x. PROP P x y)" ..
wenzelm@26570
   127
wenzelm@18466
   128
wenzelm@18466
   129
subsection {* Meta-level conjunction *}
wenzelm@18466
   130
wenzelm@18466
   131
lemma all_conjunction:
wenzelm@28856
   132
  "(!!x. PROP A x &&& PROP B x) == ((!!x. PROP A x) &&& (!!x. PROP B x))"
wenzelm@18466
   133
proof
wenzelm@28856
   134
  assume conj: "!!x. PROP A x &&& PROP B x"
wenzelm@28856
   135
  show "(!!x. PROP A x) &&& (!!x. PROP B x)"
wenzelm@19121
   136
  proof -
wenzelm@18466
   137
    fix x
wenzelm@26958
   138
    from conj show "PROP A x" by (rule conjunctionD1)
wenzelm@26958
   139
    from conj show "PROP B x" by (rule conjunctionD2)
wenzelm@18466
   140
  qed
wenzelm@18466
   141
next
wenzelm@28856
   142
  assume conj: "(!!x. PROP A x) &&& (!!x. PROP B x)"
wenzelm@18466
   143
  fix x
wenzelm@28856
   144
  show "PROP A x &&& PROP B x"
wenzelm@19121
   145
  proof -
wenzelm@26958
   146
    show "PROP A x" by (rule conj [THEN conjunctionD1, rule_format])
wenzelm@26958
   147
    show "PROP B x" by (rule conj [THEN conjunctionD2, rule_format])
wenzelm@18466
   148
  qed
wenzelm@18466
   149
qed
wenzelm@18466
   150
wenzelm@19121
   151
lemma imp_conjunction:
nipkow@50603
   152
  "(PROP A ==> PROP B &&& PROP C) == ((PROP A ==> PROP B) &&& (PROP A ==> PROP C))"
wenzelm@18836
   153
proof
wenzelm@28856
   154
  assume conj: "PROP A ==> PROP B &&& PROP C"
wenzelm@28856
   155
  show "(PROP A ==> PROP B) &&& (PROP A ==> PROP C)"
wenzelm@19121
   156
  proof -
wenzelm@18466
   157
    assume "PROP A"
wenzelm@19121
   158
    from conj [OF `PROP A`] show "PROP B" by (rule conjunctionD1)
wenzelm@19121
   159
    from conj [OF `PROP A`] show "PROP C" by (rule conjunctionD2)
wenzelm@18466
   160
  qed
wenzelm@18466
   161
next
wenzelm@28856
   162
  assume conj: "(PROP A ==> PROP B) &&& (PROP A ==> PROP C)"
wenzelm@18466
   163
  assume "PROP A"
wenzelm@28856
   164
  show "PROP B &&& PROP C"
wenzelm@19121
   165
  proof -
wenzelm@19121
   166
    from `PROP A` show "PROP B" by (rule conj [THEN conjunctionD1])
wenzelm@19121
   167
    from `PROP A` show "PROP C" by (rule conj [THEN conjunctionD2])
wenzelm@18466
   168
  qed
wenzelm@18466
   169
qed
wenzelm@18466
   170
wenzelm@18466
   171
lemma conjunction_imp:
wenzelm@28856
   172
  "(PROP A &&& PROP B ==> PROP C) == (PROP A ==> PROP B ==> PROP C)"
wenzelm@18466
   173
proof
wenzelm@28856
   174
  assume r: "PROP A &&& PROP B ==> PROP C"
wenzelm@22933
   175
  assume ab: "PROP A" "PROP B"
wenzelm@22933
   176
  show "PROP C"
wenzelm@22933
   177
  proof (rule r)
wenzelm@28856
   178
    from ab show "PROP A &&& PROP B" .
wenzelm@22933
   179
  qed
wenzelm@18466
   180
next
wenzelm@18466
   181
  assume r: "PROP A ==> PROP B ==> PROP C"
wenzelm@28856
   182
  assume conj: "PROP A &&& PROP B"
wenzelm@18466
   183
  show "PROP C"
wenzelm@18466
   184
  proof (rule r)
wenzelm@19121
   185
    from conj show "PROP A" by (rule conjunctionD1)
wenzelm@19121
   186
    from conj show "PROP B" by (rule conjunctionD2)
wenzelm@18466
   187
  qed
wenzelm@18466
   188
qed
wenzelm@18466
   189
wenzelm@48638
   190
end
wenzelm@48638
   191