37 { case Bound(a) => (Nil, int(a)) }, |
35 { case Bound(a) => (Nil, int(a)) }, |
38 { case Abs(a, b, c) => (List(a), pair(typ, term)(b, c)) }, |
36 { case Abs(a, b, c) => (List(a), pair(typ, term)(b, c)) }, |
39 { case App(a, b) => (Nil, pair(term, term)(a, b)) })) |
37 { case App(a, b) => (Nil, pair(term, term)(a, b)) })) |
40 } |
38 } |
41 |
39 |
42 object Decode |
40 object Decode { |
43 { |
|
44 import XML.Decode._ |
41 import XML.Decode._ |
45 |
42 |
46 val indexname: P[Indexname] = |
43 val indexname: P[Indexname] = |
47 { case List(a) => Indexname(a, 0) |
44 { case List(a) => Indexname(a, 0) |
48 case List(a, b) => Indexname(a, int_atom(b)) } |
45 case List(a, b) => Indexname(a, int_atom(b)) } |
64 { case (a, b) => Var(indexname(a), typ_body(b)) }, |
61 { case (a, b) => Var(indexname(a), typ_body(b)) }, |
65 { case (Nil, a) => Bound(int(a)) }, |
62 { case (Nil, a) => Bound(int(a)) }, |
66 { case (List(a), b) => val (c, d) = pair(typ, term)(b); Abs(a, c, d) }, |
63 { case (List(a), b) => val (c, d) = pair(typ, term)(b); Abs(a, c, d) }, |
67 { case (Nil, a) => val (b, c) = pair(term, term)(a); App(b, c) })) |
64 { case (Nil, a) => val (b, c) = pair(term, term)(a); App(b, c) })) |
68 |
65 |
69 def term_env(env: Map[String, Typ]): T[Term] = |
66 def term_env(env: Map[String, Typ]): T[Term] = { |
70 { |
|
71 def env_type(x: String, t: Typ): Typ = |
67 def env_type(x: String, t: Typ): Typ = |
72 if (t == dummyT && env.isDefinedAt(x)) env(x) else t |
68 if (t == dummyT && env.isDefinedAt(x)) env(x) else t |
73 |
69 |
74 def term: T[Term] = |
70 def term: T[Term] = |
75 variant[Term](List( |
71 variant[Term](List( |
80 { case (List(a), b) => val (c, d) = pair(typ, term)(b); Abs(a, c, d) }, |
76 { case (List(a), b) => val (c, d) = pair(typ, term)(b); Abs(a, c, d) }, |
81 { case (Nil, a) => val (b, c) = pair(term, term)(a); App(b, c) })) |
77 { case (Nil, a) => val (b, c) = pair(term, term)(a); App(b, c) })) |
82 term |
78 term |
83 } |
79 } |
84 |
80 |
85 def proof_env(env: Map[String, Typ]): T[Proof] = |
81 def proof_env(env: Map[String, Typ]): T[Proof] = { |
86 { |
|
87 val term = term_env(env) |
82 val term = term_env(env) |
88 def proof: T[Proof] = |
83 def proof: T[Proof] = |
89 variant[Proof](List( |
84 variant[Proof](List( |
90 { case (Nil, Nil) => MinProof }, |
85 { case (Nil, Nil) => MinProof }, |
91 { case (Nil, a) => PBound(int(a)) }, |
86 { case (Nil, a) => PBound(int(a)) }, |