src/HOL/TLA/Intensional.thy
author wenzelm
Fri, 26 Jun 2015 18:51:19 +0200
changeset 60592 c9bd1d902f04
parent 60591 e0b77517f9a9
child 61853 fb7756087101
permissions -rw-r--r--
isabelle update_cartouches;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
35108
e384e27c229f modernized syntax/translations;
wenzelm
parents: 31945
diff changeset
     1
(*  Title:      HOL/TLA/Intensional.thy
e384e27c229f modernized syntax/translations;
wenzelm
parents: 31945
diff changeset
     2
    Author:     Stephan Merz
e384e27c229f modernized syntax/translations;
wenzelm
parents: 31945
diff changeset
     3
    Copyright:  1998 University of Munich
21624
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
     4
*)
3807
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
     5
60592
c9bd1d902f04 isabelle update_cartouches;
wenzelm
parents: 60591
diff changeset
     6
section \<open>A framework for "intensional" (possible-world based) logics
c9bd1d902f04 isabelle update_cartouches;
wenzelm
parents: 60591
diff changeset
     7
  on top of HOL, with lifting of constants and functions\<close>
3807
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
     8
17309
c43ed29bd197 converted to Isar theory format;
wenzelm
parents: 14565
diff changeset
     9
theory Intensional
c43ed29bd197 converted to Isar theory format;
wenzelm
parents: 14565
diff changeset
    10
imports Main
c43ed29bd197 converted to Isar theory format;
wenzelm
parents: 14565
diff changeset
    11
begin
3807
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    12
55382
9218fa411c15 prefer vacuous definitional type classes over axiomatic ones;
wenzelm
parents: 54742
diff changeset
    13
class world
6255
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 3808
diff changeset
    14
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 3808
diff changeset
    15
(** abstract syntax **)
3807
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    16
60588
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
    17
type_synonym ('w,'a) expr = "'w \<Rightarrow> 'a"   (* intention: 'w::world, 'a::type *)
42018
878f33040280 modernized specifications;
wenzelm
parents: 41229
diff changeset
    18
type_synonym 'w form = "('w, bool) expr"
3807
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    19
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    20
consts
60588
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
    21
  Valid    :: "('w::world) form \<Rightarrow> bool"
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
    22
  const    :: "'a \<Rightarrow> ('w::world, 'a) expr"
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
    23
  lift     :: "['a \<Rightarrow> 'b, ('w::world, 'a) expr] \<Rightarrow> ('w,'b) expr"
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
    24
  lift2    :: "['a \<Rightarrow> 'b \<Rightarrow> 'c, ('w::world,'a) expr, ('w,'b) expr] \<Rightarrow> ('w,'c) expr"
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
    25
  lift3    :: "['a \<Rightarrow> 'b \<Rightarrow> 'c \<Rightarrow> 'd, ('w::world,'a) expr, ('w,'b) expr, ('w,'c) expr] \<Rightarrow> ('w,'d) expr"
3807
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    26
6255
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 3808
diff changeset
    27
  (* "Rigid" quantification (logic level) *)
60588
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
    28
  RAll     :: "('a \<Rightarrow> ('w::world) form) \<Rightarrow> 'w form"       (binder "Rall " 10)
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
    29
  REx      :: "('a \<Rightarrow> ('w::world) form) \<Rightarrow> 'w form"       (binder "Rex " 10)
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
    30
  REx1     :: "('a \<Rightarrow> ('w::world) form) \<Rightarrow> 'w form"       (binder "Rex! " 10)
3807
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    31
6255
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 3808
diff changeset
    32
(** concrete syntax **)
3807
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    33
41229
d797baa3d57c replaced command 'nonterminals' by slightly modernized version 'nonterminal';
wenzelm
parents: 38786
diff changeset
    34
nonterminal lift and liftargs
3807
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    35
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    36
syntax
60588
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
    37
  ""            :: "id \<Rightarrow> lift"                          ("_")
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
    38
  ""            :: "longid \<Rightarrow> lift"                      ("_")
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
    39
  ""            :: "var \<Rightarrow> lift"                         ("_")
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
    40
  "_applC"      :: "[lift, cargs] \<Rightarrow> lift"               ("(1_/ _)" [1000, 1000] 999)
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
    41
  ""            :: "lift \<Rightarrow> lift"                        ("'(_')")
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
    42
  "_lambda"     :: "[idts, 'a] \<Rightarrow> lift"                  ("(3\<lambda>_./ _)" [0, 3] 3)
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
    43
  "_constrain"  :: "[lift, type] \<Rightarrow> lift"                ("(_::_)" [4, 0] 3)
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
    44
  ""            :: "lift \<Rightarrow> liftargs"                    ("_")
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
    45
  "_liftargs"   :: "[lift, liftargs] \<Rightarrow> liftargs"        ("_,/ _")
60591
e0b77517f9a9 more symbols;
wenzelm
parents: 60588
diff changeset
    46
  "_Valid"      :: "lift \<Rightarrow> bool"                        ("(\<turnstile> _)" 5)
e0b77517f9a9 more symbols;
wenzelm
parents: 60588
diff changeset
    47
  "_holdsAt"    :: "['a, lift] \<Rightarrow> bool"                  ("(_ \<Turnstile> _)" [100,10] 10)
6255
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 3808
diff changeset
    48
60588
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
    49
  (* Syntax for lifted expressions outside the scope of \<turnstile> or |= *)
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
    50
  "_LIFT"       :: "lift \<Rightarrow> 'a"                          ("LIFT _")
6255
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 3808
diff changeset
    51
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 3808
diff changeset
    52
  (* generic syntax for lifted constants and functions *)
60588
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
    53
  "_const"      :: "'a \<Rightarrow> lift"                          ("(#_)" [1000] 999)
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
    54
  "_lift"       :: "['a, lift] \<Rightarrow> lift"                  ("(_<_>)" [1000] 999)
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
    55
  "_lift2"      :: "['a, lift, lift] \<Rightarrow> lift"            ("(_<_,/ _>)" [1000] 999)
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
    56
  "_lift3"      :: "['a, lift, lift, lift] \<Rightarrow> lift"      ("(_<_,/ _,/ _>)" [1000] 999)
6255
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 3808
diff changeset
    57
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 3808
diff changeset
    58
  (* concrete syntax for common infix functions: reuse same symbol *)
60588
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
    59
  "_liftEqu"    :: "[lift, lift] \<Rightarrow> lift"                ("(_ =/ _)" [50,51] 50)
60591
e0b77517f9a9 more symbols;
wenzelm
parents: 60588
diff changeset
    60
  "_liftNeq"    :: "[lift, lift] \<Rightarrow> lift"                ("(_ \<noteq>/ _)" [50,51] 50)
e0b77517f9a9 more symbols;
wenzelm
parents: 60588
diff changeset
    61
  "_liftNot"    :: "lift \<Rightarrow> lift"                        ("(\<not> _)" [40] 40)
e0b77517f9a9 more symbols;
wenzelm
parents: 60588
diff changeset
    62
  "_liftAnd"    :: "[lift, lift] \<Rightarrow> lift"                ("(_ \<and>/ _)" [36,35] 35)
e0b77517f9a9 more symbols;
wenzelm
parents: 60588
diff changeset
    63
  "_liftOr"     :: "[lift, lift] \<Rightarrow> lift"                ("(_ \<or>/ _)" [31,30] 30)
e0b77517f9a9 more symbols;
wenzelm
parents: 60588
diff changeset
    64
  "_liftImp"    :: "[lift, lift] \<Rightarrow> lift"                ("(_ \<longrightarrow>/ _)" [26,25] 25)
60588
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
    65
  "_liftIf"     :: "[lift, lift, lift] \<Rightarrow> lift"          ("(if (_)/ then (_)/ else (_))" 10)
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
    66
  "_liftPlus"   :: "[lift, lift] \<Rightarrow> lift"                ("(_ +/ _)" [66,65] 65)
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
    67
  "_liftMinus"  :: "[lift, lift] \<Rightarrow> lift"                ("(_ -/ _)" [66,65] 65)
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
    68
  "_liftTimes"  :: "[lift, lift] \<Rightarrow> lift"                ("(_ */ _)" [71,70] 70)
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
    69
  "_liftDiv"    :: "[lift, lift] \<Rightarrow> lift"                ("(_ div _)" [71,70] 70)
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
    70
  "_liftMod"    :: "[lift, lift] \<Rightarrow> lift"                ("(_ mod _)" [71,70] 70)
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
    71
  "_liftLess"   :: "[lift, lift] \<Rightarrow> lift"                ("(_/ < _)"  [50, 51] 50)
60591
e0b77517f9a9 more symbols;
wenzelm
parents: 60588
diff changeset
    72
  "_liftLeq"    :: "[lift, lift] \<Rightarrow> lift"                ("(_/ \<le> _)" [50, 51] 50)
e0b77517f9a9 more symbols;
wenzelm
parents: 60588
diff changeset
    73
  "_liftMem"    :: "[lift, lift] \<Rightarrow> lift"                ("(_/ \<in> _)" [50, 51] 50)
e0b77517f9a9 more symbols;
wenzelm
parents: 60588
diff changeset
    74
  "_liftNotMem" :: "[lift, lift] \<Rightarrow> lift"                ("(_/ \<notin> _)" [50, 51] 50)
60588
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
    75
  "_liftFinset" :: "liftargs \<Rightarrow> lift"                    ("{(_)}")
6255
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 3808
diff changeset
    76
  (** TODO: syntax for lifted collection / comprehension **)
60588
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
    77
  "_liftPair"   :: "[lift,liftargs] \<Rightarrow> lift"                   ("(1'(_,/ _'))")
6255
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 3808
diff changeset
    78
  (* infix syntax for list operations *)
60588
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
    79
  "_liftCons" :: "[lift, lift] \<Rightarrow> lift"                  ("(_ #/ _)" [65,66] 65)
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
    80
  "_liftApp"  :: "[lift, lift] \<Rightarrow> lift"                  ("(_ @/ _)" [65,66] 65)
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
    81
  "_liftList" :: "liftargs \<Rightarrow> lift"                      ("[(_)]")
6255
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 3808
diff changeset
    82
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 3808
diff changeset
    83
  (* Rigid quantification (syntax level) *)
60591
e0b77517f9a9 more symbols;
wenzelm
parents: 60588
diff changeset
    84
  "_RAll" :: "[idts, lift] \<Rightarrow> lift"                      ("(3\<forall>_./ _)" [0, 10] 10)
e0b77517f9a9 more symbols;
wenzelm
parents: 60588
diff changeset
    85
  "_REx"  :: "[idts, lift] \<Rightarrow> lift"                      ("(3\<exists>_./ _)" [0, 10] 10)
e0b77517f9a9 more symbols;
wenzelm
parents: 60588
diff changeset
    86
  "_REx1" :: "[idts, lift] \<Rightarrow> lift"                      ("(3\<exists>!_./ _)" [0, 10] 10)
3807
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    87
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    88
translations
35108
e384e27c229f modernized syntax/translations;
wenzelm
parents: 31945
diff changeset
    89
  "_const"        == "CONST const"
e384e27c229f modernized syntax/translations;
wenzelm
parents: 31945
diff changeset
    90
  "_lift"         == "CONST lift"
e384e27c229f modernized syntax/translations;
wenzelm
parents: 31945
diff changeset
    91
  "_lift2"        == "CONST lift2"
e384e27c229f modernized syntax/translations;
wenzelm
parents: 31945
diff changeset
    92
  "_lift3"        == "CONST lift3"
e384e27c229f modernized syntax/translations;
wenzelm
parents: 31945
diff changeset
    93
  "_Valid"        == "CONST Valid"
6255
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 3808
diff changeset
    94
  "_RAll x A"     == "Rall x. A"
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 3808
diff changeset
    95
  "_REx x  A"     == "Rex x. A"
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 3808
diff changeset
    96
  "_REx1 x  A"    == "Rex! x. A"
3807
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    97
60591
e0b77517f9a9 more symbols;
wenzelm
parents: 60588
diff changeset
    98
  "w \<Turnstile> A"        => "A w"
e0b77517f9a9 more symbols;
wenzelm
parents: 60588
diff changeset
    99
  "LIFT A"        => "A::_\<Rightarrow>_"
3807
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
   100
6255
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 3808
diff changeset
   101
  "_liftEqu"      == "_lift2 (op =)"
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 3808
diff changeset
   102
  "_liftNeq u v"  == "_liftNot (_liftEqu u v)"
35108
e384e27c229f modernized syntax/translations;
wenzelm
parents: 31945
diff changeset
   103
  "_liftNot"      == "_lift (CONST Not)"
60591
e0b77517f9a9 more symbols;
wenzelm
parents: 60588
diff changeset
   104
  "_liftAnd"      == "_lift2 (op \<and>)"
e0b77517f9a9 more symbols;
wenzelm
parents: 60588
diff changeset
   105
  "_liftOr"       == "_lift2 (op \<or>)"
e0b77517f9a9 more symbols;
wenzelm
parents: 60588
diff changeset
   106
  "_liftImp"      == "_lift2 (op \<longrightarrow>)"
35108
e384e27c229f modernized syntax/translations;
wenzelm
parents: 31945
diff changeset
   107
  "_liftIf"       == "_lift3 (CONST If)"
6255
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 3808
diff changeset
   108
  "_liftPlus"     == "_lift2 (op +)"
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 3808
diff changeset
   109
  "_liftMinus"    == "_lift2 (op -)"
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 3808
diff changeset
   110
  "_liftTimes"    == "_lift2 (op *)"
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 3808
diff changeset
   111
  "_liftDiv"      == "_lift2 (op div)"
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 3808
diff changeset
   112
  "_liftMod"      == "_lift2 (op mod)"
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 3808
diff changeset
   113
  "_liftLess"     == "_lift2 (op <)"
60591
e0b77517f9a9 more symbols;
wenzelm
parents: 60588
diff changeset
   114
  "_liftLeq"      == "_lift2 (op \<le>)"
e0b77517f9a9 more symbols;
wenzelm
parents: 60588
diff changeset
   115
  "_liftMem"      == "_lift2 (op \<in>)"
6255
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 3808
diff changeset
   116
  "_liftNotMem x xs"   == "_liftNot (_liftMem x xs)"
35108
e384e27c229f modernized syntax/translations;
wenzelm
parents: 31945
diff changeset
   117
  "_liftFinset (_liftargs x xs)"  == "_lift2 (CONST insert) x (_liftFinset xs)"
e384e27c229f modernized syntax/translations;
wenzelm
parents: 31945
diff changeset
   118
  "_liftFinset x" == "_lift2 (CONST insert) x (_const {})"
6255
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 3808
diff changeset
   119
  "_liftPair x (_liftargs y z)"       == "_liftPair x (_liftPair y z)"
35108
e384e27c229f modernized syntax/translations;
wenzelm
parents: 31945
diff changeset
   120
  "_liftPair"     == "_lift2 (CONST Pair)"
e384e27c229f modernized syntax/translations;
wenzelm
parents: 31945
diff changeset
   121
  "_liftCons"     == "CONST lift2 (CONST Cons)"
e384e27c229f modernized syntax/translations;
wenzelm
parents: 31945
diff changeset
   122
  "_liftApp"      == "CONST lift2 (op @)"
6255
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 3808
diff changeset
   123
  "_liftList (_liftargs x xs)"  == "_liftCons x (_liftList xs)"
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 3808
diff changeset
   124
  "_liftList x"   == "_liftCons x (_const [])"
3807
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
   125
17309
c43ed29bd197 converted to Isar theory format;
wenzelm
parents: 14565
diff changeset
   126
3807
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
   127
60591
e0b77517f9a9 more symbols;
wenzelm
parents: 60588
diff changeset
   128
  "w \<Turnstile> \<not>A"       <= "_liftNot A w"
e0b77517f9a9 more symbols;
wenzelm
parents: 60588
diff changeset
   129
  "w \<Turnstile> A \<and> B"    <= "_liftAnd A B w"
e0b77517f9a9 more symbols;
wenzelm
parents: 60588
diff changeset
   130
  "w \<Turnstile> A \<or> B"    <= "_liftOr A B w"
e0b77517f9a9 more symbols;
wenzelm
parents: 60588
diff changeset
   131
  "w \<Turnstile> A \<longrightarrow> B"  <= "_liftImp A B w"
e0b77517f9a9 more symbols;
wenzelm
parents: 60588
diff changeset
   132
  "w \<Turnstile> u = v"    <= "_liftEqu u v w"
e0b77517f9a9 more symbols;
wenzelm
parents: 60588
diff changeset
   133
  "w \<Turnstile> \<forall>x. A"   <= "_RAll x A w"
e0b77517f9a9 more symbols;
wenzelm
parents: 60588
diff changeset
   134
  "w \<Turnstile> \<exists>x. A"   <= "_REx x A w"
e0b77517f9a9 more symbols;
wenzelm
parents: 60588
diff changeset
   135
  "w \<Turnstile> \<exists>!x. A"  <= "_REx1 x A w"
3808
8489375c6198 symbols syntax;
wenzelm
parents: 3807
diff changeset
   136
35318
e1b61c5fd494 dropped axclass, going back to purely syntactic type classes
haftmann
parents: 35108
diff changeset
   137
defs
60588
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
   138
  Valid_def:   "\<turnstile> A    ==  \<forall>w. w \<Turnstile> A"
17309
c43ed29bd197 converted to Isar theory format;
wenzelm
parents: 14565
diff changeset
   139
c43ed29bd197 converted to Isar theory format;
wenzelm
parents: 14565
diff changeset
   140
  unl_con:     "LIFT #c w  ==  c"
21020
9af9ceb16d58 Adapted to changes in FixedPoint theory.
berghofe
parents: 17309
diff changeset
   141
  unl_lift:    "lift f x w == f (x w)"
17309
c43ed29bd197 converted to Isar theory format;
wenzelm
parents: 14565
diff changeset
   142
  unl_lift2:   "LIFT f<x, y> w == f (x w) (y w)"
c43ed29bd197 converted to Isar theory format;
wenzelm
parents: 14565
diff changeset
   143
  unl_lift3:   "LIFT f<x, y, z> w == f (x w) (y w) (z w)"
3807
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
   144
60588
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
   145
  unl_Rall:    "w \<Turnstile> \<forall>x. A x  ==  \<forall>x. (w \<Turnstile> A x)"
60591
e0b77517f9a9 more symbols;
wenzelm
parents: 60588
diff changeset
   146
  unl_Rex:     "w \<Turnstile> \<exists>x. A x   ==  \<exists>x. (w \<Turnstile> A x)"
60588
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
   147
  unl_Rex1:    "w \<Turnstile> \<exists>!x. A x  ==  \<exists>!x. (w \<Turnstile> A x)"
3807
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
   148
21624
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   149
60592
c9bd1d902f04 isabelle update_cartouches;
wenzelm
parents: 60591
diff changeset
   150
subsection \<open>Lemmas and tactics for "intensional" logics.\<close>
21624
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   151
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   152
lemmas intensional_rews [simp] =
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   153
  unl_con unl_lift unl_lift2 unl_lift3 unl_Rall unl_Rex unl_Rex1
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   154
60588
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
   155
lemma inteq_reflection: "\<turnstile> x=y  \<Longrightarrow>  (x==y)"
21624
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   156
  apply (unfold Valid_def unl_lift2)
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   157
  apply (rule eq_reflection)
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   158
  apply (rule ext)
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   159
  apply (erule spec)
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   160
  done
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   161
60588
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
   162
lemma intI [intro!]: "(\<And>w. w \<Turnstile> A) \<Longrightarrow> \<turnstile> A"
21624
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   163
  apply (unfold Valid_def)
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   164
  apply (rule allI)
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   165
  apply (erule meta_spec)
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   166
  done
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   167
60588
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
   168
lemma intD [dest]: "\<turnstile> A \<Longrightarrow> w \<Turnstile> A"
21624
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   169
  apply (unfold Valid_def)
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   170
  apply (erule spec)
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   171
  done
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   172
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   173
(** Lift usual HOL simplifications to "intensional" level. **)
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   174
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   175
lemma int_simps:
60588
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
   176
  "\<turnstile> (x=x) = #True"
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
   177
  "\<turnstile> (\<not>#True) = #False"  "\<turnstile> (\<not>#False) = #True"  "\<turnstile> (\<not>\<not> P) = P"
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
   178
  "\<turnstile> ((\<not>P) = P) = #False"  "\<turnstile> (P = (\<not>P)) = #False"
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
   179
  "\<turnstile> (P \<noteq> Q) = (P = (\<not>Q))"
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
   180
  "\<turnstile> (#True=P) = P"  "\<turnstile> (P=#True) = P"
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
   181
  "\<turnstile> (#True \<longrightarrow> P) = P"  "\<turnstile> (#False \<longrightarrow> P) = #True"
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
   182
  "\<turnstile> (P \<longrightarrow> #True) = #True"  "\<turnstile> (P \<longrightarrow> P) = #True"
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
   183
  "\<turnstile> (P \<longrightarrow> #False) = (\<not>P)"  "\<turnstile> (P \<longrightarrow> \<not>P) = (\<not>P)"
60591
e0b77517f9a9 more symbols;
wenzelm
parents: 60588
diff changeset
   184
  "\<turnstile> (P \<and> #True) = P"  "\<turnstile> (#True \<and> P) = P"
e0b77517f9a9 more symbols;
wenzelm
parents: 60588
diff changeset
   185
  "\<turnstile> (P \<and> #False) = #False"  "\<turnstile> (#False \<and> P) = #False"
e0b77517f9a9 more symbols;
wenzelm
parents: 60588
diff changeset
   186
  "\<turnstile> (P \<and> P) = P"  "\<turnstile> (P \<and> \<not>P) = #False"  "\<turnstile> (\<not>P \<and> P) = #False"
e0b77517f9a9 more symbols;
wenzelm
parents: 60588
diff changeset
   187
  "\<turnstile> (P \<or> #True) = #True"  "\<turnstile> (#True \<or> P) = #True"
e0b77517f9a9 more symbols;
wenzelm
parents: 60588
diff changeset
   188
  "\<turnstile> (P \<or> #False) = P"  "\<turnstile> (#False \<or> P) = P"
e0b77517f9a9 more symbols;
wenzelm
parents: 60588
diff changeset
   189
  "\<turnstile> (P \<or> P) = P"  "\<turnstile> (P \<or> \<not>P) = #True"  "\<turnstile> (\<not>P \<or> P) = #True"
60588
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
   190
  "\<turnstile> (\<forall>x. P) = P"  "\<turnstile> (\<exists>x. P) = P"
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
   191
  "\<turnstile> (\<not>Q \<longrightarrow> \<not>P) = (P \<longrightarrow> Q)"
60591
e0b77517f9a9 more symbols;
wenzelm
parents: 60588
diff changeset
   192
  "\<turnstile> (P\<or>Q \<longrightarrow> R) = ((P\<longrightarrow>R)\<and>(Q\<longrightarrow>R))"
21624
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   193
  apply (unfold Valid_def intensional_rews)
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   194
  apply blast+
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   195
  done
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   196
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   197
declare int_simps [THEN inteq_reflection, simp]
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   198
60588
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
   199
lemma TrueW [simp]: "\<turnstile> #True"
21624
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   200
  by (simp add: Valid_def unl_con)
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   201
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   202
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   203
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   204
(* ======== Functions to "unlift" intensional implications into HOL rules ====== *)
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   205
60592
c9bd1d902f04 isabelle update_cartouches;
wenzelm
parents: 60591
diff changeset
   206
ML \<open>
21624
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   207
(* Basic unlifting introduces a parameter "w" and applies basic rewrites, e.g.
60588
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
   208
   \<turnstile> F = G    becomes   F w = G w
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
   209
   \<turnstile> F \<longrightarrow> G  becomes   F w \<longrightarrow> G w
21624
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   210
*)
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   211
54742
7a86358a3c0b proper context for basic Simplifier operations: rewrite_rule, rewrite_goals_rule, rewrite_goals_tac etc.;
wenzelm
parents: 42814
diff changeset
   212
fun int_unlift ctxt th =
7a86358a3c0b proper context for basic Simplifier operations: rewrite_rule, rewrite_goals_rule, rewrite_goals_tac etc.;
wenzelm
parents: 42814
diff changeset
   213
  rewrite_rule ctxt @{thms intensional_rews} (th RS @{thm intD} handle THM _ => th);
21624
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   214
60588
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
   215
(* Turn  \<turnstile> F = G  into meta-level rewrite rule  F == G *)
54742
7a86358a3c0b proper context for basic Simplifier operations: rewrite_rule, rewrite_goals_rule, rewrite_goals_tac etc.;
wenzelm
parents: 42814
diff changeset
   216
fun int_rewrite ctxt th =
7a86358a3c0b proper context for basic Simplifier operations: rewrite_rule, rewrite_goals_rule, rewrite_goals_tac etc.;
wenzelm
parents: 42814
diff changeset
   217
  zero_var_indexes (rewrite_rule ctxt @{thms intensional_rews} (th RS @{thm inteq_reflection}))
21624
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   218
60588
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
   219
(* flattening turns "\<longrightarrow>" into "\<Longrightarrow>" and eliminates conjunctions in the
21624
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   220
   antecedent. For example,
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   221
60588
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
   222
         P & Q \<longrightarrow> (R | S \<longrightarrow> T)    becomes   \<lbrakk> P; Q; R | S \<rbrakk> \<Longrightarrow> T
21624
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   223
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   224
   Flattening can be useful with "intensional" lemmas (after unlifting).
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   225
   Naive resolution with mp and conjI may run away because of higher-order
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   226
   unification, therefore the code is a little awkward.
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   227
*)
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   228
fun flatten t =
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   229
  let
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   230
    (* analogous to RS, but using matching instead of resolution *)
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   231
    fun matchres tha i thb =
58950
d07464875dd4 optional proof context for unify operations, for the sake of proper local options;
wenzelm
parents: 58889
diff changeset
   232
      case Seq.chop 2 (Thm.biresolution NONE true [(false,tha)] i thb) of
21624
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   233
          ([th],_) => th
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   234
        | ([],_)   => raise THM("matchres: no match", i, [tha,thb])
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   235
        |      _   => raise THM("matchres: multiple unifiers", i, [tha,thb])
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   236
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   237
    (* match tha with some premise of thb *)
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   238
    fun matchsome tha thb =
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   239
      let fun hmatch 0 = raise THM("matchsome: no match", 0, [tha,thb])
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   240
            | hmatch n = matchres tha n thb handle THM _ => hmatch (n-1)
59582
0fbed69ff081 tuned signature -- prefer qualified names;
wenzelm
parents: 58950
diff changeset
   241
      in hmatch (Thm.nprems_of thb) end
21624
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   242
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   243
    fun hflatten t =
59582
0fbed69ff081 tuned signature -- prefer qualified names;
wenzelm
parents: 58950
diff changeset
   244
      case Thm.concl_of t of
0fbed69ff081 tuned signature -- prefer qualified names;
wenzelm
parents: 58950
diff changeset
   245
        Const _ $ (Const (@{const_name HOL.implies}, _) $ _ $ _) => hflatten (t RS mp)
0fbed69ff081 tuned signature -- prefer qualified names;
wenzelm
parents: 58950
diff changeset
   246
      | _ => (hflatten (matchsome conjI t)) handle THM _ => zero_var_indexes t
21624
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   247
  in
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   248
    hflatten t
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   249
  end
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   250
54742
7a86358a3c0b proper context for basic Simplifier operations: rewrite_rule, rewrite_goals_rule, rewrite_goals_tac etc.;
wenzelm
parents: 42814
diff changeset
   251
fun int_use ctxt th =
59582
0fbed69ff081 tuned signature -- prefer qualified names;
wenzelm
parents: 58950
diff changeset
   252
    case Thm.concl_of th of
56256
1e01c159e7d9 more antiquotations;
wenzelm
parents: 55382
diff changeset
   253
      Const _ $ (Const (@{const_name Valid}, _) $ _) =>
54742
7a86358a3c0b proper context for basic Simplifier operations: rewrite_rule, rewrite_goals_rule, rewrite_goals_tac etc.;
wenzelm
parents: 42814
diff changeset
   254
              (flatten (int_unlift ctxt th) handle THM _ => th)
21624
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   255
    | _ => th
60592
c9bd1d902f04 isabelle update_cartouches;
wenzelm
parents: 60591
diff changeset
   256
\<close>
21624
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   257
54742
7a86358a3c0b proper context for basic Simplifier operations: rewrite_rule, rewrite_goals_rule, rewrite_goals_tac etc.;
wenzelm
parents: 42814
diff changeset
   258
attribute_setup int_unlift =
60592
c9bd1d902f04 isabelle update_cartouches;
wenzelm
parents: 60591
diff changeset
   259
  \<open>Scan.succeed (Thm.rule_attribute (int_unlift o Context.proof_of))\<close>
54742
7a86358a3c0b proper context for basic Simplifier operations: rewrite_rule, rewrite_goals_rule, rewrite_goals_tac etc.;
wenzelm
parents: 42814
diff changeset
   260
attribute_setup int_rewrite =
60592
c9bd1d902f04 isabelle update_cartouches;
wenzelm
parents: 60591
diff changeset
   261
  \<open>Scan.succeed (Thm.rule_attribute (int_rewrite o Context.proof_of))\<close>
c9bd1d902f04 isabelle update_cartouches;
wenzelm
parents: 60591
diff changeset
   262
attribute_setup flatten = \<open>Scan.succeed (Thm.rule_attribute (K flatten))\<close>
54742
7a86358a3c0b proper context for basic Simplifier operations: rewrite_rule, rewrite_goals_rule, rewrite_goals_tac etc.;
wenzelm
parents: 42814
diff changeset
   263
attribute_setup int_use =
60592
c9bd1d902f04 isabelle update_cartouches;
wenzelm
parents: 60591
diff changeset
   264
  \<open>Scan.succeed (Thm.rule_attribute (int_use o Context.proof_of))\<close>
21624
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   265
60588
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
   266
lemma Not_Rall: "\<turnstile> (\<not>(\<forall>x. F x)) = (\<exists>x. \<not>F x)"
21624
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   267
  by (simp add: Valid_def)
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   268
60588
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
   269
lemma Not_Rex: "\<turnstile> (\<not> (\<exists>x. F x)) = (\<forall>x. \<not> F x)"
21624
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   270
  by (simp add: Valid_def)
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   271
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 21020
diff changeset
   272
end