src/HOLCF/ex/Focus_ex.thy
author wenzelm
Tue, 06 Sep 2005 19:28:58 +0200
changeset 17291 94f6113fe9ed
parent 10835 f4745d77e620
child 19742 86f21beabafc
permissions -rw-r--r--
converted to Isar theory format;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
17291
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
     1
(* $Id$ *)
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
     2
2570
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
     3
(* Specification of the following loop back device
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
     4
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
     5
17291
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
     6
          g
2570
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
     7
           --------------------
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
     8
          |      -------       |
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
     9
       x  |     |       |      |  y
17291
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
    10
    ------|---->|       |------| ----->
2570
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    11
          |  z  |   f   | z    |
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    12
          |  -->|       |---   |
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    13
          | |   |       |   |  |
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    14
          | |    -------    |  |
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    15
          | |               |  |
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    16
          |  <--------------   |
17291
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
    17
          |                    |
2570
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    18
           --------------------
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    19
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    20
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    21
First step: Notation in Agent Network Description Language (ANDL)
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    22
-----------------------------------------------------------------
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    23
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    24
agent f
17291
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
    25
        input  channel i1:'b i2: ('b,'c) tc
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
    26
        output channel o1:'c o2: ('b,'c) tc
2570
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    27
is
17291
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
    28
        Rf(i1,i2,o1,o2)  (left open in the example)
2570
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    29
end f
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    30
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    31
agent g
17291
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
    32
        input  channel x:'b
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
    33
        output channel y:'c
2570
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    34
is network
17291
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
    35
        <y,z> = f$<x,z>
2570
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    36
end network
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    37
end g
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    38
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    39
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    40
Remark: the type of the feedback depends at most on the types of the input and
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    41
        output of g. (No type miracles inside g)
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    42
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    43
Second step: Translation of ANDL specification to HOLCF Specification
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    44
---------------------------------------------------------------------
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    45
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    46
Specification of agent f ist translated to predicate is_f
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    47
17291
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
    48
is_f :: ('b stream * ('b,'c) tc stream ->
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
    49
                'c stream * ('b,'c) tc stream) => bool
2570
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    50
17291
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
    51
is_f f  = !i1 i2 o1 o2.
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
    52
        f$<i1,i2> = <o1,o2> --> Rf(i1,i2,o1,o2)
2570
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    53
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    54
Specification of agent g is translated to predicate is_g which uses
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    55
predicate is_net_g
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    56
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    57
is_net_g :: ('b stream * ('b,'c) tc stream -> 'c stream * ('b,'c) tc stream) =>
17291
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
    58
            'b stream => 'c stream => bool
2570
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    59
17291
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
    60
is_net_g f x y =
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
    61
        ? z. <y,z> = f$<x,z> &
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
    62
        !oy hz. <oy,hz> = f$<x,hz> --> z << hz
2570
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    63
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    64
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    65
is_g :: ('b stream -> 'c stream) => bool
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    66
10835
nipkow
parents: 3842
diff changeset
    67
is_g g  = ? f. is_f f  & (!x y. g$x = y --> is_net_g f x y
17291
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
    68
2570
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    69
Third step: (show conservativity)
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    70
-----------
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    71
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    72
Suppose we have a model for the theory TH1 which contains the axiom
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    73
17291
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
    74
        ? f. is_f f
2570
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    75
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    76
In this case there is also a model for the theory TH2 that enriches TH1 by
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    77
axiom
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    78
17291
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
    79
        ? g. is_g g
2570
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    80
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    81
The result is proved by showing that there is a definitional extension
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    82
that extends TH1 by a definition of g.
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    83
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    84
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    85
We define:
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    86
17291
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
    87
def_g g  =
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
    88
         (? f. is_f f  &
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
    89
              g = (LAM x. cfst$(f$<x,fix$(LAM k.csnd$(f$<x,k>))>)) )
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
    90
2570
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    91
Now we prove:
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    92
17291
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
    93
        (? f. is_f f ) --> (? g. is_g g)
2570
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    94
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    95
using the theorems
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    96
17291
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
    97
loopback_eq)    def_g = is_g                    (real work)
2570
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    98
17291
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
    99
L1)             (? f. is_f f ) --> (? g. def_g g)  (trivial)
2570
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
   100
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
   101
*)
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
   102
17291
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
   103
theory Focus_ex
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
   104
imports Stream
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
   105
begin
2570
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
   106
17291
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
   107
typedecl ('a, 'b) tc
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
   108
arities tc:: (pcpo, pcpo) pcpo
2570
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
   109
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
   110
consts
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
   111
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
   112
is_f     ::
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
   113
 "('b stream * ('b,'c) tc stream -> 'c stream * ('b,'c) tc stream) => bool"
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
   114
is_net_g :: "('b stream *('b,'c) tc stream -> 'c stream * ('b,'c) tc stream) =>
17291
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
   115
            'b stream => 'c stream => bool"
2570
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
   116
is_g     :: "('b stream -> 'c stream) => bool"
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
   117
def_g    :: "('b stream -> 'c stream) => bool"
17291
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
   118
Rf       ::
2570
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
   119
"('b stream * ('b,'c) tc stream * 'c stream * ('b,'c) tc stream) => bool"
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
   120
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
   121
defs
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
   122
17291
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
   123
is_f:           "is_f f == (!i1 i2 o1 o2.
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
   124
                        f$<i1,i2> = <o1,o2> --> Rf(i1,i2,o1,o2))"
2570
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
   125
17291
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
   126
is_net_g:       "is_net_g f x y == (? z.
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
   127
                        <y,z> = f$<x,z> &
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
   128
                        (!oy hz. <oy,hz> = f$<x,hz> --> z << hz))"
2570
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
   129
17291
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
   130
is_g:           "is_g g  == (? f.
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
   131
                        is_f f  &
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
   132
                        (!x y. g$x = y --> is_net_g f x y))"
2570
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
   133
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
   134
17291
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
   135
def_g:          "def_g g == (? f.
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
   136
                        is_f f  &
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
   137
                        g = (LAM x. cfst$(f$<x,fix$(LAM  k. csnd$(f$<x,k>))>)))"
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
   138
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
   139
ML {* use_legacy_bindings (the_context ()) *}
2570
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
   140
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
   141
end