equal
deleted
inserted
replaced
1 (* Title: ZF/Tools/inductive_package.ML |
1 (* Title: ZF/Tools/inductive_package.ML |
2 ID: $Id$ |
|
3 Author: Lawrence C Paulson, Cambridge University Computer Laboratory |
2 Author: Lawrence C Paulson, Cambridge University Computer Laboratory |
4 Copyright 1994 University of Cambridge |
|
5 |
3 |
6 Fixedpoint definition module -- for Inductive/Coinductive Definitions |
4 Fixedpoint definition module -- for Inductive/Coinductive Definitions |
7 |
5 |
8 The functor will be instantiated for normal sums/products (inductive defs) |
6 The functor will be instantiated for normal sums/products (inductive defs) |
9 and non-standard sums/products (coinductive defs) |
7 and non-standard sums/products (coinductive defs) |
111 |
109 |
112 (*Makes a disjunct from an introduction rule*) |
110 (*Makes a disjunct from an introduction rule*) |
113 fun fp_part intr = (*quantify over rule's free vars except parameters*) |
111 fun fp_part intr = (*quantify over rule's free vars except parameters*) |
114 let val prems = map dest_tprop (Logic.strip_imp_prems intr) |
112 let val prems = map dest_tprop (Logic.strip_imp_prems intr) |
115 val dummy = List.app (fn rec_hd => List.app (chk_prem rec_hd) prems) rec_hds |
113 val dummy = List.app (fn rec_hd => List.app (chk_prem rec_hd) prems) rec_hds |
116 val exfrees = term_frees intr \\ rec_params |
114 val exfrees = OldTerm.term_frees intr \\ rec_params |
117 val zeq = FOLogic.mk_eq (Free(z',iT), #1 (rule_concl intr)) |
115 val zeq = FOLogic.mk_eq (Free(z',iT), #1 (rule_concl intr)) |
118 in foldr FOLogic.mk_exists |
116 in foldr FOLogic.mk_exists |
119 (BalancedTree.make FOLogic.mk_conj (zeq::prems)) exfrees |
117 (BalancedTree.make FOLogic.mk_conj (zeq::prems)) exfrees |
120 end; |
118 end; |
121 |
119 |
302 in subst_free (map mk_sb ind_alist) prem :: iprems end) |
300 in subst_free (map mk_sb ind_alist) prem :: iprems end) |
303 | add_induct_prem ind_alist (prem,iprems) = prem :: iprems; |
301 | add_induct_prem ind_alist (prem,iprems) = prem :: iprems; |
304 |
302 |
305 (*Make a premise of the induction rule.*) |
303 (*Make a premise of the induction rule.*) |
306 fun induct_prem ind_alist intr = |
304 fun induct_prem ind_alist intr = |
307 let val quantfrees = map dest_Free (term_frees intr \\ rec_params) |
305 let val quantfrees = map dest_Free (OldTerm.term_frees intr \\ rec_params) |
308 val iprems = foldr (add_induct_prem ind_alist) [] |
306 val iprems = foldr (add_induct_prem ind_alist) [] |
309 (Logic.strip_imp_prems intr) |
307 (Logic.strip_imp_prems intr) |
310 val (t,X) = Ind_Syntax.rule_concl intr |
308 val (t,X) = Ind_Syntax.rule_concl intr |
311 val (SOME pred) = AList.lookup (op aconv) ind_alist X |
309 val (SOME pred) = AList.lookup (op aconv) ind_alist X |
312 val concl = FOLogic.mk_Trueprop (pred $ t) |
310 val concl = FOLogic.mk_Trueprop (pred $ t) |