src/HOL/HOLCF/ex/Focus_ex.thy
author haftmann
Thu, 19 Jun 2025 17:15:40 +0200
changeset 82734 89347c0cc6a3
parent 69597 ff784d5a5bfb
permissions -rw-r--r--
treat map_filter similar to list_all, list_ex, list_ex1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2570
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
     1
(* Specification of the following loop back device
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
     2
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
     3
17291
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
     4
          g
2570
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
     5
           --------------------
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
     6
          |      -------       |
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
     7
       x  |     |       |      |  y
17291
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
     8
    ------|---->|       |------| ----->
2570
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
     9
          |  z  |   f   | z    |
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    10
          |  -->|       |---   |
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    11
          | |   |       |   |  |
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
          |  <--------------   |
17291
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
    15
          |                    |
2570
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    16
           --------------------
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    17
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    18
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    19
First step: Notation in Agent Network Description Language (ANDL)
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    20
-----------------------------------------------------------------
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    21
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    22
agent f
17291
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
    23
        input  channel i1:'b i2: ('b,'c) tc
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
    24
        output channel o1:'c o2: ('b,'c) tc
2570
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    25
is
17291
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
    26
        Rf(i1,i2,o1,o2)  (left open in the example)
2570
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    27
end f
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    28
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    29
agent g
17291
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
    30
        input  channel x:'b
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
    31
        output channel y:'c
2570
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    32
is network
35916
d5c5fc1b993b use Pair, fst, snd instead of cpair, cfst, csnd
huffman
parents: 35174
diff changeset
    33
        (y,z) = f$(x,z)
2570
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    34
end network
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    35
end g
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    36
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    37
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    38
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
    39
        output of g. (No type miracles inside g)
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    40
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    41
Second step: Translation of ANDL specification to HOLCF Specification
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    42
---------------------------------------------------------------------
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    43
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    44
Specification of agent f ist translated to predicate is_f
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    45
17291
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
    46
is_f :: ('b stream * ('b,'c) tc stream ->
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
    47
                'c stream * ('b,'c) tc stream) => bool
2570
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    48
17291
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
    49
is_f f  = !i1 i2 o1 o2.
35916
d5c5fc1b993b use Pair, fst, snd instead of cpair, cfst, csnd
huffman
parents: 35174
diff changeset
    50
        f$(i1,i2) = (o1,o2) --> Rf(i1,i2,o1,o2)
2570
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    51
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    52
Specification of agent g is translated to predicate is_g which uses
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    53
predicate is_net_g
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    54
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    55
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
    56
            'b stream => 'c stream => bool
2570
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    57
17291
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
    58
is_net_g f x y =
35916
d5c5fc1b993b use Pair, fst, snd instead of cpair, cfst, csnd
huffman
parents: 35174
diff changeset
    59
        ? z. (y,z) = f$(x,z) &
d5c5fc1b993b use Pair, fst, snd instead of cpair, cfst, csnd
huffman
parents: 35174
diff changeset
    60
        !oy hz. (oy,hz) = f$(x,hz) --> z << hz
2570
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    61
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    62
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    63
is_g :: ('b stream -> 'c stream) => bool
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    64
10835
nipkow
parents: 3842
diff changeset
    65
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
    66
2570
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    67
Third step: (show conservativity)
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    68
-----------
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    69
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    70
Suppose we have a model for the theory TH1 which contains the axiom
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    71
17291
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
    72
        ? f. is_f f
2570
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    73
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    74
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
    75
axiom
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    76
17291
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
    77
        ? g. is_g g
2570
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    78
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    79
The result is proved by showing that there is a definitional extension
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    80
that extends TH1 by a definition of g.
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    81
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    82
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    83
We define:
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    84
17291
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
    85
def_g g  =
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
    86
         (? f. is_f f  &
35916
d5c5fc1b993b use Pair, fst, snd instead of cpair, cfst, csnd
huffman
parents: 35174
diff changeset
    87
              g = (LAM x. fst (f$(x,fix$(LAM k. snd (f$(x,k)))))) )
17291
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
    88
2570
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    89
Now we prove:
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    90
17291
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
    91
        (? f. is_f f ) --> (? g. is_g g)
2570
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    92
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    93
using the theorems
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    94
17291
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
    95
loopback_eq)    def_g = is_g                    (real work)
2570
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    96
17291
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
    97
L1)             (? f. is_f f ) --> (? g. def_g g)  (trivial)
2570
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    98
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    99
*)
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
   100
17291
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
   101
theory Focus_ex
66453
cc19f7ca2ed6 session-qualified theory imports: isabelle imports -U -i -d '~~/src/Benchmarks' -a;
wenzelm
parents: 63549
diff changeset
   102
imports "HOLCF-Library.Stream"
17291
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
   103
begin
2570
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
   104
17291
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
   105
typedecl ('a, 'b) tc
55381
ca31f042414f more explicit axiomatization;
wenzelm
parents: 51717
diff changeset
   106
axiomatization where tc_arity: "OFCLASS(('a::pcpo, 'b::pcpo) tc, pcop_class)"
ca31f042414f more explicit axiomatization;
wenzelm
parents: 51717
diff changeset
   107
instance tc :: (pcpo, pcpo) pcpo by (rule tc_arity)
2570
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
   108
25135
4f8176c940cf modernized specifications ('definition', 'axiomatization');
wenzelm
parents: 21404
diff changeset
   109
axiomatization
63549
b0d31c7def86 more symbols;
wenzelm
parents: 62175
diff changeset
   110
  Rf :: "('b stream * ('b,'c) tc stream * 'c stream * ('b,'c) tc stream) \<Rightarrow> bool"
2570
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
   111
19763
wenzelm
parents: 19742
diff changeset
   112
definition
63549
b0d31c7def86 more symbols;
wenzelm
parents: 62175
diff changeset
   113
  is_f :: "('b stream * ('b,'c) tc stream \<rightarrow> 'c stream * ('b,'c) tc stream) \<Rightarrow> bool" where
b0d31c7def86 more symbols;
wenzelm
parents: 62175
diff changeset
   114
  "is_f f \<longleftrightarrow> (\<forall>i1 i2 o1 o2. f\<cdot>(i1, i2) = (o1, o2) \<longrightarrow> Rf (i1, i2, o1, o2))"
2570
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
   115
21404
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 19763
diff changeset
   116
definition
63549
b0d31c7def86 more symbols;
wenzelm
parents: 62175
diff changeset
   117
  is_net_g :: "('b stream * ('b,'c) tc stream \<rightarrow> 'c stream * ('b,'c) tc stream) \<Rightarrow>
b0d31c7def86 more symbols;
wenzelm
parents: 62175
diff changeset
   118
    'b stream \<Rightarrow> 'c stream \<Rightarrow> bool" where
b0d31c7def86 more symbols;
wenzelm
parents: 62175
diff changeset
   119
  "is_net_g f x y \<equiv> (\<exists>z.
b0d31c7def86 more symbols;
wenzelm
parents: 62175
diff changeset
   120
                        (y, z) = f\<cdot>(x,z) \<and>
b0d31c7def86 more symbols;
wenzelm
parents: 62175
diff changeset
   121
                        (\<forall>oy hz. (oy, hz) = f\<cdot>(x, hz) \<longrightarrow> z << hz))"
2570
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
   122
21404
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 19763
diff changeset
   123
definition
63549
b0d31c7def86 more symbols;
wenzelm
parents: 62175
diff changeset
   124
  is_g :: "('b stream \<rightarrow> 'c stream) \<Rightarrow> bool" where
b0d31c7def86 more symbols;
wenzelm
parents: 62175
diff changeset
   125
  "is_g g \<equiv> (\<exists>f. is_f f \<and> (\<forall>x y. g\<cdot>x = y \<longrightarrow> is_net_g f x y))"
2570
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
   126
21404
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 19763
diff changeset
   127
definition
63549
b0d31c7def86 more symbols;
wenzelm
parents: 62175
diff changeset
   128
  def_g :: "('b stream \<rightarrow> 'c stream) => bool" where
b0d31c7def86 more symbols;
wenzelm
parents: 62175
diff changeset
   129
  "def_g g \<equiv> (\<exists>f. is_f f \<and> g = (LAM x. fst (f\<cdot>(x, fix\<cdot>(LAM  k. snd (f\<cdot>(x, k)))))))"
17291
94f6113fe9ed converted to Isar theory format;
wenzelm
parents: 10835
diff changeset
   130
19742
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   131
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   132
(* first some logical trading *)
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   133
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   134
lemma lemma1:
63549
b0d31c7def86 more symbols;
wenzelm
parents: 62175
diff changeset
   135
  "is_g g \<longleftrightarrow>
b0d31c7def86 more symbols;
wenzelm
parents: 62175
diff changeset
   136
    (\<exists>f. is_f(f) \<and> (\<forall>x.(\<exists>z. (g\<cdot>x,z) = f\<cdot>(x,z) \<and> (\<forall>w y. (y, w) = f\<cdot>(x, w) \<longrightarrow> z << w))))"
19763
wenzelm
parents: 19742
diff changeset
   137
apply (simp add: is_g_def is_net_g_def)
19742
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   138
apply fast
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   139
done
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   140
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   141
lemma lemma2:
63549
b0d31c7def86 more symbols;
wenzelm
parents: 62175
diff changeset
   142
  "(\<exists>f. is_f f \<and> (\<forall>x. (\<exists>z. (g\<cdot>x, z) = f\<cdot>(x, z) \<and> (\<forall>w y. (y, w) = f\<cdot>(x,w) \<longrightarrow> z << w)))) \<longleftrightarrow>
b0d31c7def86 more symbols;
wenzelm
parents: 62175
diff changeset
   143
  (\<exists>f. is_f f \<and> (\<forall>x. \<exists>z.
b0d31c7def86 more symbols;
wenzelm
parents: 62175
diff changeset
   144
        g\<cdot>x = fst (f\<cdot>(x, z)) \<and>
b0d31c7def86 more symbols;
wenzelm
parents: 62175
diff changeset
   145
          z = snd (f\<cdot>(x, z)) \<and>
b0d31c7def86 more symbols;
wenzelm
parents: 62175
diff changeset
   146
        (\<forall>w y. (y, w) = f\<cdot>(x, w) \<longrightarrow> z << w)))"
19742
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   147
apply (rule iffI)
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   148
apply (erule exE)
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   149
apply (rule_tac x = "f" in exI)
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   150
apply (erule conjE)+
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   151
apply (erule conjI)
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   152
apply (intro strip)
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   153
apply (erule allE)
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   154
apply (erule exE)
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   155
apply (rule_tac x = "z" in exI)
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   156
apply (erule conjE)+
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   157
apply (rule conjI)
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   158
apply (rule_tac [2] conjI)
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   159
prefer 3 apply (assumption)
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   160
apply (drule sym)
40028
9ee4e0ab2964 remove old uses of 'simp_tac HOLCF_ss'
huffman
parents: 40002
diff changeset
   161
apply (simp)
19742
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   162
apply (drule sym)
40028
9ee4e0ab2964 remove old uses of 'simp_tac HOLCF_ss'
huffman
parents: 40002
diff changeset
   163
apply (simp)
19742
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   164
apply (erule exE)
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   165
apply (rule_tac x = "f" in exI)
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   166
apply (erule conjE)+
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   167
apply (erule conjI)
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   168
apply (intro strip)
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   169
apply (erule allE)
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   170
apply (erule exE)
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   171
apply (rule_tac x = "z" in exI)
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   172
apply (erule conjE)+
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   173
apply (rule conjI)
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   174
prefer 2 apply (assumption)
35916
d5c5fc1b993b use Pair, fst, snd instead of cpair, cfst, csnd
huffman
parents: 35174
diff changeset
   175
apply (rule prod_eqI)
d5c5fc1b993b use Pair, fst, snd instead of cpair, cfst, csnd
huffman
parents: 35174
diff changeset
   176
apply simp
d5c5fc1b993b use Pair, fst, snd instead of cpair, cfst, csnd
huffman
parents: 35174
diff changeset
   177
apply simp
19742
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   178
done
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   179
63549
b0d31c7def86 more symbols;
wenzelm
parents: 62175
diff changeset
   180
lemma lemma3: "def_g g \<longrightarrow> is_g g"
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 66453
diff changeset
   181
apply (tactic \<open>simp_tac (put_simpset HOL_ss \<^context>
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 55381
diff changeset
   182
  addsimps [@{thm def_g_def}, @{thm lemma1}, @{thm lemma2}]) 1\<close>)
19742
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   183
apply (rule impI)
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   184
apply (erule exE)
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   185
apply (rule_tac x = "f" in exI)
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   186
apply (erule conjE)+
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   187
apply (erule conjI)
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   188
apply (intro strip)
63549
b0d31c7def86 more symbols;
wenzelm
parents: 62175
diff changeset
   189
apply (rule_tac x = "fix\<cdot>(LAM k. snd (f\<cdot>(x, k)))" in exI)
19742
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   190
apply (rule conjI)
40028
9ee4e0ab2964 remove old uses of 'simp_tac HOLCF_ss'
huffman
parents: 40002
diff changeset
   191
 apply (simp)
35916
d5c5fc1b993b use Pair, fst, snd instead of cpair, cfst, csnd
huffman
parents: 35174
diff changeset
   192
 apply (rule prod_eqI, simp, simp)
19742
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   193
 apply (rule trans)
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   194
  apply (rule fix_eq)
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   195
 apply (simp (no_asm))
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   196
apply (intro strip)
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   197
apply (rule fix_least)
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   198
apply (simp (no_asm))
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   199
apply (erule exE)
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   200
apply (drule sym)
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   201
back
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   202
apply simp
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   203
done
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   204
63549
b0d31c7def86 more symbols;
wenzelm
parents: 62175
diff changeset
   205
lemma lemma4: "is_g g \<longrightarrow> def_g g"
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 66453
diff changeset
   206
apply (tactic \<open>simp_tac (put_simpset HOL_ss \<^context>
51717
9e7d1c139569 simplifier uses proper Proof.context instead of historic type simpset;
wenzelm
parents: 41413
diff changeset
   207
  delsimps (@{thms HOL.ex_simps} @ @{thms HOL.all_simps})
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 55381
diff changeset
   208
  addsimps [@{thm lemma1}, @{thm lemma2}, @{thm def_g_def}]) 1\<close>)
19742
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   209
apply (rule impI)
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   210
apply (erule exE)
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   211
apply (rule_tac x = "f" in exI)
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   212
apply (erule conjE)+
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   213
apply (erule conjI)
40002
c5b5f7a3a3b1 new theorem names: fun_below_iff, fun_belowI, cfun_eq_iff, cfun_eqI, cfun_below_iff, cfun_belowI
huffman
parents: 39159
diff changeset
   214
apply (rule cfun_eqI)
19742
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   215
apply (erule_tac x = "x" in allE)
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   216
apply (erule exE)
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   217
apply (erule conjE)+
63549
b0d31c7def86 more symbols;
wenzelm
parents: 62175
diff changeset
   218
apply (subgoal_tac "fix\<cdot>(LAM k. snd (f\<cdot>(x, k))) = z")
19742
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   219
 apply simp
63549
b0d31c7def86 more symbols;
wenzelm
parents: 62175
diff changeset
   220
apply (subgoal_tac "\<forall>w y. f\<cdot>(x, w) = (y, w) \<longrightarrow> z << w")
19742
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   221
apply (rule fix_eqI)
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   222
apply simp
63549
b0d31c7def86 more symbols;
wenzelm
parents: 62175
diff changeset
   223
apply (subgoal_tac "f\<cdot>(x, za) = (fst (f\<cdot>(x, za)), za)")
19742
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   224
apply fast
35916
d5c5fc1b993b use Pair, fst, snd instead of cpair, cfst, csnd
huffman
parents: 35174
diff changeset
   225
apply (rule prod_eqI, simp, simp)
19742
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   226
apply (intro strip)
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   227
apply (erule allE)+
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   228
apply (erule mp)
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   229
apply (erule sym)
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   230
done
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   231
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   232
(* now we assemble the result *)
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   233
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   234
lemma loopback_eq: "def_g = is_g"
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   235
apply (rule ext)
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   236
apply (rule iffI)
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   237
apply (erule lemma3 [THEN mp])
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   238
apply (erule lemma4 [THEN mp])
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   239
done
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   240
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   241
lemma L2:
63549
b0d31c7def86 more symbols;
wenzelm
parents: 62175
diff changeset
   242
  "(\<exists>f. is_f (f::'b stream * ('b,'c) tc stream \<rightarrow> 'c stream * ('b,'c) tc stream)) \<longrightarrow>
b0d31c7def86 more symbols;
wenzelm
parents: 62175
diff changeset
   243
    (\<exists>g. def_g (g::'b stream \<rightarrow> 'c stream))"
19763
wenzelm
parents: 19742
diff changeset
   244
apply (simp add: def_g_def)
19742
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   245
done
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   246
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   247
theorem conservative_loopback:
63549
b0d31c7def86 more symbols;
wenzelm
parents: 62175
diff changeset
   248
  "(\<exists>f. is_f (f::'b stream * ('b,'c) tc stream \<rightarrow> 'c stream * ('b,'c) tc stream)) \<longrightarrow>
b0d31c7def86 more symbols;
wenzelm
parents: 62175
diff changeset
   249
    (\<exists>g. is_g (g::'b stream \<rightarrow> 'c stream))"
19742
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   250
apply (rule loopback_eq [THEN subst])
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   251
apply (rule L2)
86f21beabafc removed legacy ML scripts;
wenzelm
parents: 17291
diff changeset
   252
done
2570
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
   253
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
   254
end