src/HOL/Lex/Scanner.thy
author nipkow
Mon, 13 May 2002 15:27:28 +0200
changeset 13145 59bc43b51aa2
parent 12792 b344226f924c
permissions -rw-r--r--
*** empty log message ***
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4907
0eb6730de30f Reshuffeling, renaming and a few simple corollaries.
nipkow
parents:
diff changeset
     1
(*  Title:      HOL/Lex/Scanner.thy
0eb6730de30f Reshuffeling, renaming and a few simple corollaries.
nipkow
parents:
diff changeset
     2
    ID:         $Id$
0eb6730de30f Reshuffeling, renaming and a few simple corollaries.
nipkow
parents:
diff changeset
     3
    Author:     Tobias Nipkow
0eb6730de30f Reshuffeling, renaming and a few simple corollaries.
nipkow
parents:
diff changeset
     4
    Copyright   1998 TUM
0eb6730de30f Reshuffeling, renaming and a few simple corollaries.
nipkow
parents:
diff changeset
     5
*)
0eb6730de30f Reshuffeling, renaming and a few simple corollaries.
nipkow
parents:
diff changeset
     6
12792
b344226f924c Added code generation to Scanner.thy
nipkow
parents: 5323
diff changeset
     7
theory Scanner = Automata + RegExp2NA + RegExp2NAe:
b344226f924c Added code generation to Scanner.thy
nipkow
parents: 5323
diff changeset
     8
b344226f924c Added code generation to Scanner.thy
nipkow
parents: 5323
diff changeset
     9
theorem "DA.accepts (na2da(rexp2na r)) w = (w : lang r)"
b344226f924c Added code generation to Scanner.thy
nipkow
parents: 5323
diff changeset
    10
by (simp add: NA_DA_equiv[THEN sym] accepts_rexp2na)
b344226f924c Added code generation to Scanner.thy
nipkow
parents: 5323
diff changeset
    11
b344226f924c Added code generation to Scanner.thy
nipkow
parents: 5323
diff changeset
    12
theorem  "DA.accepts (nae2da(rexp2nae r)) w = (w : lang r)"
b344226f924c Added code generation to Scanner.thy
nipkow
parents: 5323
diff changeset
    13
by (simp add: NAe_DA_equiv accepts_rexp2nae)
b344226f924c Added code generation to Scanner.thy
nipkow
parents: 5323
diff changeset
    14
b344226f924c Added code generation to Scanner.thy
nipkow
parents: 5323
diff changeset
    15
(* Testing code generation: *)
b344226f924c Added code generation to Scanner.thy
nipkow
parents: 5323
diff changeset
    16
b344226f924c Added code generation to Scanner.thy
nipkow
parents: 5323
diff changeset
    17
types_code
b344226f924c Added code generation to Scanner.thy
nipkow
parents: 5323
diff changeset
    18
  set ("_ list")
b344226f924c Added code generation to Scanner.thy
nipkow
parents: 5323
diff changeset
    19
b344226f924c Added code generation to Scanner.thy
nipkow
parents: 5323
diff changeset
    20
consts_code
b344226f924c Added code generation to Scanner.thy
nipkow
parents: 5323
diff changeset
    21
  "{}"     ("[]")
b344226f924c Added code generation to Scanner.thy
nipkow
parents: 5323
diff changeset
    22
  "insert" ("(_ ins _)")
b344226f924c Added code generation to Scanner.thy
nipkow
parents: 5323
diff changeset
    23
  "op :"   ("(_ mem _)")
b344226f924c Added code generation to Scanner.thy
nipkow
parents: 5323
diff changeset
    24
  "op Un"  ("(_ union _)")
b344226f924c Added code generation to Scanner.thy
nipkow
parents: 5323
diff changeset
    25
  "image"  ("map")
b344226f924c Added code generation to Scanner.thy
nipkow
parents: 5323
diff changeset
    26
  "UNION"  ("(fn A => fn f => flat(map f A))")
b344226f924c Added code generation to Scanner.thy
nipkow
parents: 5323
diff changeset
    27
  "Bex"    ("(fn A => fn f => exists f A)")
b344226f924c Added code generation to Scanner.thy
nipkow
parents: 5323
diff changeset
    28
b344226f924c Added code generation to Scanner.thy
nipkow
parents: 5323
diff changeset
    29
generate_code
b344226f924c Added code generation to Scanner.thy
nipkow
parents: 5323
diff changeset
    30
  test = "let r0 = Atom(0::nat);
b344226f924c Added code generation to Scanner.thy
nipkow
parents: 5323
diff changeset
    31
              r1 = Atom(1::nat);
b344226f924c Added code generation to Scanner.thy
nipkow
parents: 5323
diff changeset
    32
              re = Conc (Star(Or(Conc r1 r1)r0))
b344226f924c Added code generation to Scanner.thy
nipkow
parents: 5323
diff changeset
    33
                        (Star(Or(Conc r0 r0)r1));
b344226f924c Added code generation to Scanner.thy
nipkow
parents: 5323
diff changeset
    34
              N = rexp2na re;
b344226f924c Added code generation to Scanner.thy
nipkow
parents: 5323
diff changeset
    35
              D = na2da N
b344226f924c Added code generation to Scanner.thy
nipkow
parents: 5323
diff changeset
    36
          in (NA.accepts N [0,1,1,0,0,1], DA.accepts D [0,1,1,0,0,1])"
b344226f924c Added code generation to Scanner.thy
nipkow
parents: 5323
diff changeset
    37
ML test
b344226f924c Added code generation to Scanner.thy
nipkow
parents: 5323
diff changeset
    38
b344226f924c Added code generation to Scanner.thy
nipkow
parents: 5323
diff changeset
    39
end