isahipster: 8866715a911da841acd55c3a0691087d68b2c3fe
1: theory regexp_RecPlus
2: imports Main
3: "$HIPSTER_HOME/IsaHipster"
4: begin
5:
6: datatype 'a list = Nil2 | Cons2 "'a" "'a list"
7:
8: datatype A = X | Y
9:
10: datatype R
11: = Nil2 | Eps | Atom "A" | Plus "R" "R" | Seq "R" "R" | Star "R"
12:
13: fun seq :: "R => R => R" where
14: "seq x y =
15: case x of
16: | other =>
17: case y of
18: | other =>
19: case x of
20: | other =>
21: case y of
22: | other => Seq x y
23: | Eps => x
24: end
25: | Eps => y
26: end
27: | Nil2 => y
28: end
29: | Nil2 => x
30: end"
31:
32: fun plus :: "R => R => R" where
33: "plus x y =
34: case x of
35: | other =>
36: case y of
37: | other => Plus x y
38: | Nil2 => x
39: end
40: | Nil2 => y
41: end"
42:
43: fun or2 :: "bool => bool => bool" where
44: "or2 True y = True"
45: | "or2 False y = y"
46:
47: fun eqA :: "A => A => bool" where
48: "eqA (X) y = False"
49: | "eqA (Y) (X) = False"
50: | "eqA (Y) (Y) = True"
51:
52: fun and2 :: "bool => bool => bool" where
53: "and2 True y = y"
54: | "and2 False y = False"
55:
56: fun eps :: "R => bool" where
57: "eps x =
58: case x of
59: | other => False
60: | Eps => True
61: | Plus p q => or2 (eps p) (eps q)
62: | Seq p2 q2 => and2 (eps p2) (eps q2)
63: | Star y => True
64: end"
65:
66: fun epsR :: "R => R" where
67: "epsR x = (if eps x then Eps else Nil2)"
68:
69: fun step :: "R => A => R" where
70: "step x y =
71: case x of
72: | other => Nil2
73: | Atom a => (if eqA a y then Eps else Nil2)
74: | Plus p q => plus (step p y) (step q y)
75: | Seq p2 q2 =>
76: plus (seq (step p2 y) q2) (seq (epsR p2) (step q2 y))
77: | Star p3 => seq (step p3 y) x
78: end"
79:
80: fun recognise :: "R => A list => bool" where
81: "recognise x (Nil2) = eps x"
82: | "recognise x (Cons2 z xs) = recognise (step x z) xs"
83:
84: (*hipster seq plus or2 eqA and2 eps epsR step recognise *)
85:
86: theorem x0 :
87: "!! (p :: R) (q :: R) (s :: A list) .
88: (recognise (Plus p q) s) = (or2 (recognise p s) (recognise q s))"
89: by (tactic {* Subgoal.FOCUS_PARAMS (K (Tactic_Data.hard_tac @{context})) @{context} 1 *})
90:
91: end
Generated by git2html.