src/HOL/TLA/Intensional.thy
author wenzelm
Fri Nov 09 00:09:47 2001 +0100 (2001-11-09)
changeset 12114 a8e860c86252
parent 9517 f58863b1406a
child 12338 de0f4a63baa5
permissions -rw-r--r--
eliminated old "symbols" syntax, use "xsymbols" instead;
wenzelm@3807
     1
(* 
wenzelm@3807
     2
    File:	 TLA/Intensional.thy
wenzelm@3807
     3
    Author:      Stephan Merz
wenzelm@6255
     4
    Copyright:   1998 University of Munich
wenzelm@3807
     5
wenzelm@3807
     6
    Theory Name: Intensional
wenzelm@3807
     7
    Logic Image: HOL
wenzelm@3807
     8
wenzelm@3807
     9
Define a framework for "intensional" (possible-world based) logics
wenzelm@3807
    10
on top of HOL, with lifting of constants and functions.
wenzelm@3807
    11
*)
wenzelm@3807
    12
wenzelm@6255
    13
Intensional  =  Main +
wenzelm@3807
    14
wenzelm@6255
    15
axclass
wenzelm@6255
    16
  world < term
wenzelm@6255
    17
wenzelm@6255
    18
(** abstract syntax **)
wenzelm@3807
    19
wenzelm@3807
    20
types
wenzelm@6255
    21
  ('w,'a) expr = 'w => 'a               (* intention: 'w::world, 'a::term *)
wenzelm@6255
    22
  'w form = ('w, bool) expr
wenzelm@3807
    23
wenzelm@3807
    24
consts
wenzelm@6255
    25
  Valid    :: ('w::world) form => bool
wenzelm@6255
    26
  const    :: 'a => ('w::world, 'a) expr
wenzelm@6255
    27
  lift     :: ['a => 'b, ('w::world, 'a) expr] => ('w,'b) expr
wenzelm@6255
    28
  lift2    :: ['a => 'b => 'c, ('w::world,'a) expr, ('w,'b) expr] => ('w,'c) expr
wenzelm@6255
    29
  lift3    :: ['a => 'b => 'c => 'd, ('w::world,'a) expr, ('w,'b) expr, ('w,'c) expr] => ('w,'d) expr
wenzelm@3807
    30
wenzelm@6255
    31
  (* "Rigid" quantification (logic level) *)
wenzelm@6255
    32
  RAll     :: "('a => ('w::world) form) => 'w form"       (binder "Rall " 10)
wenzelm@6255
    33
  REx      :: "('a => ('w::world) form) => 'w form"       (binder "Rex " 10)
wenzelm@6255
    34
  REx1     :: "('a => ('w::world) form) => 'w form"       (binder "Rex! " 10)
wenzelm@3807
    35
wenzelm@6255
    36
(** concrete syntax **)
wenzelm@3807
    37
wenzelm@6255
    38
nonterminals
wenzelm@6255
    39
  lift
wenzelm@6255
    40
  liftargs
wenzelm@3807
    41
wenzelm@3807
    42
syntax
wenzelm@6255
    43
  ""            :: id => lift                          ("_")
wenzelm@6255
    44
  ""            :: longid => lift                      ("_")
wenzelm@6255
    45
  ""            :: var => lift                         ("_")
wenzelm@6255
    46
  "_applC"      :: [lift, cargs] => lift               ("(1_/ _)" [1000, 1000] 999)
wenzelm@6255
    47
  ""            :: lift => lift                        ("'(_')")
wenzelm@6255
    48
  "_lambda"     :: [idts, 'a] => lift                  ("(3%_./ _)" [0, 3] 3)
wenzelm@6255
    49
  "_constrain"  :: [lift, type] => lift                ("(_::_)" [4, 0] 3)
wenzelm@6255
    50
  ""            :: lift => liftargs                    ("_")
wenzelm@6255
    51
  "_liftargs"   :: [lift, liftargs] => liftargs        ("_,/ _")
wenzelm@6255
    52
  "_Valid"      :: lift => bool                        ("(|- _)" 5)
wenzelm@6255
    53
  "_holdsAt"    :: ['a, lift] => bool                  ("(_ |= _)" [100,10] 10)
wenzelm@6255
    54
wenzelm@6255
    55
  (* Syntax for lifted expressions outside the scope of |- or |= *)
wenzelm@6255
    56
  "LIFT"        :: lift => 'a                          ("LIFT _")
wenzelm@6255
    57
wenzelm@6255
    58
  (* generic syntax for lifted constants and functions *)
wenzelm@6255
    59
  "_const"      :: 'a => lift                          ("(#_)" [1000] 999)
wenzelm@6255
    60
  "_lift"       :: ['a, lift] => lift                  ("(_<_>)" [1000] 999)
wenzelm@6255
    61
  "_lift2"      :: ['a, lift, lift] => lift            ("(_<_,/ _>)" [1000] 999)
wenzelm@6255
    62
  "_lift3"      :: ['a, lift, lift, lift] => lift      ("(_<_,/ _,/ _>)" [1000] 999)
wenzelm@6255
    63
wenzelm@6255
    64
  (* concrete syntax for common infix functions: reuse same symbol *)
wenzelm@6255
    65
  "_liftEqu"    :: [lift, lift] => lift                ("(_ =/ _)" [50,51] 50)
wenzelm@6255
    66
  "_liftNeq"    :: [lift, lift] => lift                ("(_ ~=/ _)" [50,51] 50)
wenzelm@6255
    67
  "_liftNot"    :: lift => lift                        ("(~ _)" [40] 40)
wenzelm@6255
    68
  "_liftAnd"    :: [lift, lift] => lift                ("(_ &/ _)" [36,35] 35)
wenzelm@6255
    69
  "_liftOr"     :: [lift, lift] => lift                ("(_ |/ _)" [31,30] 30)
wenzelm@6255
    70
  "_liftImp"    :: [lift, lift] => lift                ("(_ -->/ _)" [26,25] 25)
wenzelm@6255
    71
  "_liftIf"     :: [lift, lift, lift] => lift          ("(if (_)/ then (_)/ else (_))" 10)
wenzelm@6255
    72
  "_liftPlus"   :: [lift, lift] => lift                ("(_ +/ _)" [66,65] 65)
wenzelm@6255
    73
  "_liftMinus"  :: [lift, lift] => lift                ("(_ -/ _)" [66,65] 65)
wenzelm@6255
    74
  "_liftTimes"  :: [lift, lift] => lift                ("(_ */ _)" [71,70] 70)
wenzelm@6255
    75
  "_liftDiv"    :: [lift, lift] => lift                ("(_ div _)" [71,70] 70)
wenzelm@6255
    76
  "_liftMod"    :: [lift, lift] => lift                ("(_ mod _)" [71,70] 70)
wenzelm@6255
    77
  "_liftLess"   :: [lift, lift] => lift                ("(_/ < _)"  [50, 51] 50)
wenzelm@6255
    78
  "_liftLeq"    :: [lift, lift] => lift                ("(_/ <= _)" [50, 51] 50)
wenzelm@6255
    79
  "_liftMem"    :: [lift, lift] => lift                ("(_/ : _)" [50, 51] 50)
wenzelm@6255
    80
  "_liftNotMem" :: [lift, lift] => lift                ("(_/ ~: _)" [50, 51] 50)
wenzelm@6255
    81
  "_liftFinset" :: liftargs => lift                    ("{(_)}")
wenzelm@6255
    82
  (** TODO: syntax for lifted collection / comprehension **)
wenzelm@6255
    83
  "_liftPair"   :: [lift,liftargs] => lift                   ("(1'(_,/ _'))")
wenzelm@6255
    84
  (* infix syntax for list operations *)
wenzelm@9517
    85
  "_liftCons" :: [lift, lift] => lift                  ("(_ #/ _)" [65,66] 65)
wenzelm@9517
    86
  "_liftApp"  :: [lift, lift] => lift                  ("(_ @/ _)" [65,66] 65)
wenzelm@9517
    87
  "_liftList" :: liftargs => lift                      ("[(_)]")
wenzelm@6255
    88
wenzelm@6255
    89
  (* Rigid quantification (syntax level) *)
wenzelm@9517
    90
  "_ARAll"  :: [idts, lift] => lift                    ("(3! _./ _)" [0, 10] 10)
wenzelm@9517
    91
  "_AREx"   :: [idts, lift] => lift                    ("(3? _./ _)" [0, 10] 10)
wenzelm@9517
    92
  "_AREx1"  :: [idts, lift] => lift                    ("(3?! _./ _)" [0, 10] 10)
wenzelm@9517
    93
  "_RAll" :: [idts, lift] => lift                      ("(3ALL _./ _)" [0, 10] 10)
wenzelm@9517
    94
  "_REx"  :: [idts, lift] => lift                      ("(3EX _./ _)" [0, 10] 10)
wenzelm@9517
    95
  "_REx1" :: [idts, lift] => lift                      ("(3EX! _./ _)" [0, 10] 10)
wenzelm@3807
    96
wenzelm@3807
    97
translations
wenzelm@6255
    98
  "_const"        == "const"
wenzelm@6255
    99
  "_lift"         == "lift"
wenzelm@6255
   100
  "_lift2"        == "lift2"
wenzelm@6255
   101
  "_lift3"        == "lift3"
wenzelm@6255
   102
  "_Valid"        == "Valid"
wenzelm@6255
   103
  "_RAll x A"     == "Rall x. A"
wenzelm@6255
   104
  "_REx x  A"     == "Rex x. A"
wenzelm@6255
   105
  "_REx1 x  A"    == "Rex! x. A"
wenzelm@6255
   106
  "_ARAll"        => "_RAll"
wenzelm@6255
   107
  "_AREx"         => "_REx"
wenzelm@6255
   108
  "_AREx1"        => "_REx1"
wenzelm@3807
   109
wenzelm@6255
   110
  "w |= A"        => "A w"
wenzelm@6255
   111
  "LIFT A"        => "A::_=>_"
wenzelm@3807
   112
wenzelm@6255
   113
  "_liftEqu"      == "_lift2 (op =)"
wenzelm@6255
   114
  "_liftNeq u v"  == "_liftNot (_liftEqu u v)"
wenzelm@6255
   115
  "_liftNot"      == "_lift Not"
wenzelm@6255
   116
  "_liftAnd"      == "_lift2 (op &)"
wenzelm@6255
   117
  "_liftOr"       == "_lift2 (op | )"
wenzelm@6255
   118
  "_liftImp"      == "_lift2 (op -->)"
wenzelm@6255
   119
  "_liftIf"       == "_lift3 If"
wenzelm@6255
   120
  "_liftPlus"     == "_lift2 (op +)"
wenzelm@6255
   121
  "_liftMinus"    == "_lift2 (op -)"
wenzelm@6255
   122
  "_liftTimes"    == "_lift2 (op *)"
wenzelm@6255
   123
  "_liftDiv"      == "_lift2 (op div)"
wenzelm@6255
   124
  "_liftMod"      == "_lift2 (op mod)"
wenzelm@6255
   125
  "_liftLess"     == "_lift2 (op <)"
wenzelm@6255
   126
  "_liftLeq"      == "_lift2 (op <=)"
wenzelm@6255
   127
  "_liftMem"      == "_lift2 (op :)"
wenzelm@6255
   128
  "_liftNotMem x xs"   == "_liftNot (_liftMem x xs)"
wenzelm@6255
   129
  "_liftFinset (_liftargs x xs)"  == "_lift2 insert x (_liftFinset xs)"
wenzelm@6255
   130
  "_liftFinset x" == "_lift2 insert x (_const {})"
wenzelm@6255
   131
  "_liftPair x (_liftargs y z)"       == "_liftPair x (_liftPair y z)"
wenzelm@6255
   132
  "_liftPair"     == "_lift2 Pair"
wenzelm@7224
   133
  "_liftCons"     == "lift2 Cons"
wenzelm@6255
   134
  "_liftApp"      == "lift2 (op @)"
wenzelm@6255
   135
  "_liftList (_liftargs x xs)"  == "_liftCons x (_liftList xs)"
wenzelm@6255
   136
  "_liftList x"   == "_liftCons x (_const [])"
wenzelm@3807
   137
wenzelm@6255
   138
  
wenzelm@3807
   139
wenzelm@6255
   140
  "w |= ~A"       <= "_liftNot A w"
wenzelm@6255
   141
  "w |= A & B"    <= "_liftAnd A B w"
wenzelm@6255
   142
  "w |= A | B"    <= "_liftOr A B w"
wenzelm@6255
   143
  "w |= A --> B"  <= "_liftImp A B w"
wenzelm@6255
   144
  "w |= u = v"    <= "_liftEqu u v w"
wenzelm@9517
   145
  "w |= ALL x. A"   <= "_RAll x A w"
wenzelm@9517
   146
  "w |= EX x. A"   <= "_REx x A w"
wenzelm@9517
   147
  "w |= EX! x. A"  <= "_REx1 x A w"
wenzelm@3807
   148
wenzelm@12114
   149
syntax (xsymbols)
wenzelm@6255
   150
  "_Valid"      :: lift => bool                        ("(\\<turnstile> _)" 5)
wenzelm@6255
   151
  "_holdsAt"    :: ['a, lift] => bool                  ("(_ \\<Turnstile> _)" [100,10] 10)
wenzelm@6255
   152
  "_liftNeq"    :: [lift, lift] => lift                (infixl "\\<noteq>" 50)
wenzelm@6255
   153
  "_liftNot"    :: lift => lift                        ("\\<not> _" [40] 40)
wenzelm@6255
   154
  "_liftAnd"    :: [lift, lift] => lift                (infixr "\\<and>" 35)
wenzelm@6255
   155
  "_liftOr"     :: [lift, lift] => lift                (infixr "\\<or>" 30)
wenzelm@12114
   156
  "_liftImp"    :: [lift, lift] => lift                (infixr "\\<longrightarrow>" 25)
wenzelm@6255
   157
  "_RAll"       :: [idts, lift] => lift                ("(3\\<forall>_./ _)" [0, 10] 10)
wenzelm@6255
   158
  "_REx"        :: [idts, lift] => lift                ("(3\\<exists>_./ _)" [0, 10] 10)
wenzelm@6255
   159
  "_REx1"       :: [idts, lift] => lift                ("(3\\<exists>!_./ _)" [0, 10] 10)
wenzelm@6255
   160
  "_liftLeq"    :: [lift, lift] => lift                ("(_/ \\<le> _)" [50, 51] 50)
wenzelm@6255
   161
  "_liftMem"    :: [lift, lift] => lift                ("(_/ \\<in> _)" [50, 51] 50)
wenzelm@6255
   162
  "_liftNotMem" :: [lift, lift] => lift                ("(_/ \\<notin> _)" [50, 51] 50)
wenzelm@3808
   163
wenzelm@6340
   164
syntax (HTML output)
wenzelm@6340
   165
  "_liftNot"    :: lift => lift                        ("\\<not> _" [40] 40)
wenzelm@6340
   166
wenzelm@3807
   167
rules
wenzelm@6255
   168
  Valid_def   "|- A    ==  ALL w. w |= A"
wenzelm@3807
   169
wenzelm@6255
   170
  unl_con     "LIFT #c w  ==  c" 
wenzelm@6255
   171
  unl_lift    "LIFT f<x> w == f (x w)"
wenzelm@6255
   172
  unl_lift2   "LIFT f<x, y> w == f (x w) (y w)"
wenzelm@6255
   173
  unl_lift3   "LIFT f<x, y, z> w == f (x w) (y w) (z w)"
wenzelm@3807
   174
wenzelm@9517
   175
  unl_Rall    "w |= ALL x. A x  ==  ALL x. (w |= A x)" 
wenzelm@9517
   176
  unl_Rex     "w |= EX x. A x   ==  EX x. (w |= A x)"
wenzelm@9517
   177
  unl_Rex1    "w |= EX! x. A x  ==  EX! x. (w |= A x)"
wenzelm@6255
   178
end