22 |
22 |
23 (** Abstract syntax definitions for ZF **) |
23 (** Abstract syntax definitions for ZF **) |
24 |
24 |
25 val iT = Type("i",[]); |
25 val iT = Type("i",[]); |
26 |
26 |
27 val mem_const = Const("op :", [iT,iT]--->FOLogic.oT); |
27 val mem_const = @{term mem}; |
28 |
28 |
29 (*Creates All(%v.v:A --> P(v)) rather than Ball(A,P) *) |
29 (*Creates All(%v.v:A --> P(v)) rather than Ball(A,P) *) |
30 fun mk_all_imp (A,P) = |
30 fun mk_all_imp (A,P) = |
31 FOLogic.all_const iT $ |
31 FOLogic.all_const iT $ |
32 Abs("v", iT, FOLogic.imp $ (mem_const $ Bound 0 $ A) $ |
32 Abs("v", iT, FOLogic.imp $ (mem_const $ Bound 0 $ A) $ |
33 Term.betapply(P, Bound 0)); |
33 Term.betapply(P, Bound 0)); |
34 |
34 |
35 val Part_const = Const("Part", [iT,iT-->iT]--->iT); |
35 val Part_const = Const("Part", [iT,iT-->iT]--->iT); |
36 |
36 |
37 val apply_const = Const("op `", [iT,iT]--->iT); |
37 val apply_const = @{term apply}; |
38 |
38 |
39 val Vrecursor_const = Const("Univ.Vrecursor", [[iT,iT]--->iT, iT]--->iT); |
39 val Vrecursor_const = Const("Univ.Vrecursor", [[iT,iT]--->iT, iT]--->iT); |
40 |
40 |
41 val Collect_const = Const("Collect", [iT, iT-->FOLogic.oT] ---> iT); |
41 val Collect_const = Const("Collect", [iT, iT-->FOLogic.oT] ---> iT); |
42 fun mk_Collect (a,D,t) = Collect_const $ D $ absfree(a, iT, t); |
42 fun mk_Collect (a,D,t) = Collect_const $ D $ absfree(a, iT, t); |
43 |
43 |
44 (*simple error-checking in the premises of an inductive definition*) |
44 (*simple error-checking in the premises of an inductive definition*) |
45 fun chk_prem rec_hd (Const("op &",_) $ _ $ _) = |
45 fun chk_prem rec_hd (Const("op &",_) $ _ $ _) = |
46 error"Premises may not be conjuctive" |
46 error"Premises may not be conjuctive" |
47 | chk_prem rec_hd (Const("op :",_) $ t $ X) = |
47 | chk_prem rec_hd (Const(@{const_name mem},_) $ t $ X) = |
48 (Logic.occs(rec_hd,t) andalso error "Recursion term on left of member symbol"; ()) |
48 (Logic.occs(rec_hd,t) andalso error "Recursion term on left of member symbol"; ()) |
49 | chk_prem rec_hd t = |
49 | chk_prem rec_hd t = |
50 (Logic.occs(rec_hd,t) andalso error "Recursion term in side formula"; ()); |
50 (Logic.occs(rec_hd,t) andalso error "Recursion term in side formula"; ()); |
51 |
51 |
52 (*Return the conclusion of a rule, of the form t:X*) |
52 (*Return the conclusion of a rule, of the form t:X*) |
53 fun rule_concl rl = |
53 fun rule_concl rl = |
54 let val Const("Trueprop",_) $ (Const("op :",_) $ t $ X) = |
54 let val Const("Trueprop",_) $ (Const(@{const_name mem},_) $ t $ X) = |
55 Logic.strip_imp_concl rl |
55 Logic.strip_imp_concl rl |
56 in (t,X) end; |
56 in (t,X) end; |
57 |
57 |
58 (*As above, but return error message if bad*) |
58 (*As above, but return error message if bad*) |
59 fun rule_concl_msg sign rl = rule_concl rl |
59 fun rule_concl_msg sign rl = rule_concl rl |
72 (*Constructor name, type, mixfix info; |
72 (*Constructor name, type, mixfix info; |
73 internal name from mixfix, datatype sets, full premises*) |
73 internal name from mixfix, datatype sets, full premises*) |
74 type constructor_spec = |
74 type constructor_spec = |
75 ((string * typ * mixfix) * string * term list * term list); |
75 ((string * typ * mixfix) * string * term list * term list); |
76 |
76 |
77 fun dest_mem (Const("op :",_) $ x $ A) = (x,A) |
77 fun dest_mem (Const(@{const_name mem},_) $ x $ A) = (x,A) |
78 | dest_mem _ = error "Constructor specifications must have the form x:A"; |
78 | dest_mem _ = error "Constructor specifications must have the form x:A"; |
79 |
79 |
80 (*read a constructor specification*) |
80 (*read a constructor specification*) |
81 fun read_construct sign (id, sprems, syn) = |
81 fun read_construct sign (id, sprems, syn) = |
82 let val prems = map (Sign.simple_read_term sign FOLogic.oT) sprems |
82 let val prems = map (Sign.simple_read_term sign FOLogic.oT) sprems |
100 $ rec_tm)) |
100 $ rec_tm)) |
101 in map mk_intr constructs end; |
101 in map mk_intr constructs end; |
102 |
102 |
103 fun mk_all_intr_tms sg arg = List.concat (ListPair.map (mk_intr_tms sg) arg); |
103 fun mk_all_intr_tms sg arg = List.concat (ListPair.map (mk_intr_tms sg) arg); |
104 |
104 |
105 fun mk_Un (t1, t2) = Const("op Un", [iT,iT]--->iT) $ t1 $ t2; |
105 fun mk_Un (t1, t2) = Const(@{const_name Un}, [iT,iT]--->iT) $ t1 $ t2; |
106 |
106 |
107 val empty = Const("0", iT) |
107 val empty = Const("0", iT) |
108 and univ = Const("Univ.univ", iT-->iT) |
108 and univ = Const("Univ.univ", iT-->iT) |
109 and quniv = Const("QUniv.quniv", iT-->iT); |
109 and quniv = Const("QUniv.quniv", iT-->iT); |
110 |
110 |