Literature/Slind
author wu
Mon, 13 Aug 2012 12:08:52 +0000
changeset 364 21428f38e506
parent 249 061b32d78471
permissions -rw-r--r--
add comments by christian
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
249
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
     1
A student who is attempting to prove the pumping lemma for regular
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
     2
languages came across the following problem. Suppose a DFA is
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
     3
represented by a record  <| init ; trans ; accept |> where
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
     4
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
     5
         init : 'state
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
     6
         trans : 'state -> 'symbol -> 'state
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
     7
         accept : 'state -> bool
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
     8
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
     9
Execution of a DFA on a string:
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    10
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    11
    (Execute machine [] s = s)
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    12
    (Execute machine (h::t) s = Execute machine t (machine.trans s h))
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    13
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    14
Language recognized by a machine  D:
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    15
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    16
   Lang(D) = {x | D.accept (Execute D x D.init)}
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    17
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    18
These are all accepted by HOL with no problem. In then trying to define 
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    19
the
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    20
set of regular languages, namely those accepted by some DFA, the 
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    21
following
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    22
is natural to try
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    23
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    24
    Regular (L:'symbol list -> bool) =  ?D. L = Lang(D)
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    25
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    26
But this fails, since D has two type variables ('state and 'symbol) but
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    27
Regular is a predicate on 'symbol lists. So the principle of definition
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    28
rejects.
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    29
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    30
So now my questions.
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    31
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    32
1. Is there a work-around (other than not attempting to define Regular,
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    33
     or defining regularity through some other device, like regular 
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    34
expressions).
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    35
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    36
2. I'm aware that examples of this kind have cropped up from time to 
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    37
time,
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    38
     and I'd like to hear of any others you've encountered.
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    39
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    40
Thanks,
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    41
Konrad.
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    42
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    43
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    44
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    45
-----------------------------------------
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    46
Hi Konrad,
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    47
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    48
|     Regular (L:'symbol list -> bool) =  ?D. L = Lang(D)
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    49
|
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    50
| But this fails, since D has two type variables ('state and 'symbol) but
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    51
| Regular is a predicate on 'symbol lists. So the principle of definition
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    52
| rejects.
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    53
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    54
This is a classic case where adding quantifiers over type variables, as
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    55
once suggested by Tom Melham, would really help.
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    56
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    57
| 2. I'm aware that examples of this kind have cropped up from time to 
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    58
| time, and I'd like to hear of any others you've encountered.
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    59
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    60
The metatheory of first order logic (this is close to Hasan's example).
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    61
In the work I reported at TPHOLs'98 I wanted to define the notion of
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    62
"satisfiable" for first order formulas, but this cannot be done in the
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    63
straightforward way you'd like. See the end of section 3 of:
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    64
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    65
  http://www.cl.cam.ac.uk/users/jrh/papers/model.html
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    66
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    67
| 1. Is there a work-around (other than not attempting to define Regular,
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    68
|      or defining regularity through some other device, like regular 
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    69
| expressions).
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    70
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    71
You could define it over some type you "know" to be adequate, such
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    72
as numbers (Rob) or equivalence classes of symbol lists (Ching Tsun).
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    73
Then you could validate the definition by proving that it implies
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    74
the analogous thing over any type. In first-order logic, this was
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    75
precisely one of the key things I wanted to prove anyway (the
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    76
downward Loewenheim-Skolem theorem) so it wasn't wasted effort.
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    77
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    78
 |- (?M:(A)model. M satisfies p) ==> (?M:(num)model. M satisfies p)
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    79
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    80
Where "A" is a type variable. That's an abstraction of the actual
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    81
statement proved, which is given towards the end of section 4.
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    82
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    83
John.
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    84
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    85
-----------------------------------------------------
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    86
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    87
On Apr 21, 2005, at 1:10 PM, Rob Arthan wrote:
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    88
>>
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    89
>> So now my questions.
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    90
>>
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    91
>> 1. Is there a work-around (other than not attempting to define 
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    92
>> Regular,
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    93
>>     or defining regularity through some other device, like regular 
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    94
>> expressions).
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    95
>
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    96
> I was going to say: instantiate 'state to num in the definition - 
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    97
> after all, DFAs only have finitely many states so the states can 
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    98
> always be represented by numbers.
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
    99
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
   100
Good idea.
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
   101
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
   102
>
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
   103
> But your student's definitions don't captured the tiniteness 
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
   104
> requirement. And they need to! As things stand every language L is 
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
   105
> regular via the machine with states being lists of symbols and with
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
   106
>
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
   107
>     init = []
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
   108
>     trans st sym = st @ [sym]
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
   109
>     accept = L
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
   110
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
   111
Good example, sorry about my shoddy presentation: I gave an overly 
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
   112
simplified
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
   113
version. A better version would be something like the following:
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
   114
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
   115
Hol_datatype `dfa = <| states  : 'a -> bool ;
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
   116
                                          symbols : 'b -> bool ;
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
   117
                                          init    : 'a ;
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
   118
                                          trans   : 'a->'b->'a ;
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
   119
                                          accept  : 'a -> bool |>`;
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
   120
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
   121
  Define
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
   122
    `DFA(M) =
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
   123
            FINITE M.states /\
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
   124
            FINITE M.symbols /\
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
   125
             ~(M.states = {}) /\
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
   126
             ~(M.symbols = {}) /\
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
   127
             M.accept SUBSET M.states /\
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
   128
             M.init IN M.states /\
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
   129
             !(a:'symbol) (s:'state).
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
   130
                  a IN M.symbols /\ s IN M.states ==> (M.trans s a) IN 
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
   131
M.states`;
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
   132
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
   133
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
   134
Define `(Exec D [] s = s) /\
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
   135
               (Exec D (h::t) s = Exec D t (D.trans s h))`;
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
   136
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
   137
Define `Lang D = {x | D.accept (Exec D x D.init)}`;
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
   138
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
   139
(* Urk! *)
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
   140
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
   141
Define `Regular L = ?D::DFA. L = Lang D`;
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
   142
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
   143
>
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
   144
> if you take account of finiteness properly, then instantiating 'state 
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
   145
> to num will give the right answer.; And it gives another proof 
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
   146
> opportunity!  (Namely to prove that the instantiated definition is 
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
   147
> equivalent to the definition you really wanted).
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
   148
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
   149
That's a nice bit of spin: a proof opportunity!
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
   150
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
   151
>
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
   152
>>
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
   153
>> 2. I'm aware that examples of this kind have cropped up from time to 
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
   154
>> time,
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
   155
>>     and I'd like to hear of any others you've encountered.
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
   156
>>
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
   157
>
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
   158
> Free algebraic structures provide a vast set of examples.
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
   159
>
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
   160
>
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
   161
Very interesting. Can you give some specific examples?
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
   162
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
   163
Thanks,
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
   164
Konrad.
061b32d78471 a final polishing before submitting later this week
urbanc
parents:
diff changeset
   165