equal
deleted
inserted
replaced
97 val pre_bnfss = map #pre_bnfs fp_sugars; |
97 val pre_bnfss = map #pre_bnfs fp_sugars; |
98 val nesty_bnfss = map (fn sugar => #nested_bnfs sugar @ #nesting_bnfs sugar) fp_sugars; |
98 val nesty_bnfss = map (fn sugar => #nested_bnfs sugar @ #nesting_bnfs sugar) fp_sugars; |
99 val fp_nesty_bnfss = fp_bnfs :: nesty_bnfss; |
99 val fp_nesty_bnfss = fp_bnfs :: nesty_bnfss; |
100 val fp_nesty_bnfs = distinct eq_bnf (flat fp_nesty_bnfss); |
100 val fp_nesty_bnfs = distinct eq_bnf (flat fp_nesty_bnfss); |
101 |
101 |
102 fun abstract t = |
|
103 let val Ts = Term.add_frees t []; |
|
104 in fold_rev Term.absfree (filter (member op = Ts) phis') t end; |
|
105 |
|
106 val rels = |
102 val rels = |
107 let |
103 let |
108 fun find_rel T As Bs = fp_nesty_bnfss |
104 fun find_rel T As Bs = fp_nesty_bnfss |
109 |> map (filter_out (curry eq_bnf BNF_Comp.DEADID_bnf)) |
105 |> map (filter_out (curry eq_bnf BNF_Comp.DEADID_bnf)) |
110 |> get_first (find_first (fn bnf => Type.could_unify (T_of_bnf bnf, T))) |
106 |> get_first (find_first (fn bnf => Type.could_unify (T_of_bnf bnf, T))) |
123 end |
119 end |
124 | mk_rel (T as TFree _) _ = (nth phis (find_index (curry op = T) As) |
120 | mk_rel (T as TFree _) _ = (nth phis (find_index (curry op = T) As) |
125 handle General.Subscript => HOLogic.eq_const T) |
121 handle General.Subscript => HOLogic.eq_const T) |
126 | mk_rel _ _ = raise Fail "fpTs contains schematic type variables"; |
122 | mk_rel _ _ = raise Fail "fpTs contains schematic type variables"; |
127 in |
123 in |
128 map2 (abstract oo mk_rel) fpTs fpTs' |
124 map2 (fold_rev Term.absfree phis' oo mk_rel) fpTs fpTs' |
129 end; |
125 end; |
130 |
126 |
131 val pre_rels = map2 (fn Ds => mk_rel_of_bnf Ds (As @ fpTs) (Bs @ fpTs')) Dss bnfs; |
127 val pre_rels = map2 (fn Ds => mk_rel_of_bnf Ds (As @ fpTs) (Bs @ fpTs')) Dss bnfs; |
132 |
128 |
133 val rel_unfoldss = map (maps (fn bnf => no_refl [rel_def_of_bnf bnf])) pre_bnfss; |
129 val rel_unfoldss = map (maps (fn bnf => no_refl [rel_def_of_bnf bnf])) pre_bnfss; |