|
| 1 | +open holSyntaxSyntax |
| 2 | + |
| 3 | +val theory_ok_hol_ctxt = prove( |
| 4 | + ``theory_ok (thyof hol_ctxt)``, |
| 5 | + match_mp_tac (MP_CANON extends_theory_ok) >> |
| 6 | + match_exists_tac (concl hol_extends_bool) >> |
| 7 | + simp[hol_extends_bool,bool_theory_ok]) |
| 8 | + |
| 9 | +val exists_equal_thm = prove( |
| 10 | + ``$? ($= x) ⇔ T``, |
| 11 | + `$= x = λz. x = z` by ( simp[FUN_EQ_THM] ) >> |
| 12 | + pop_assum SUBST1_TAC >> simp[]) |
| 13 | +val exists_REV_ASSOCD_thm = prove( |
| 14 | + ``∃i. ty = REV_ASSOCD (Tyvar a) i (Tyvar a)``, |
| 15 | + qexists_tac`[ty,Tyvar a]` >> |
| 16 | + EVAL_TAC ) |
| 17 | + |
| 18 | +val cs = list_compset() |
| 19 | +val () = pairLib.add_pair_compset cs |
| 20 | +val () = stringLib.add_string_compset cs |
| 21 | +val () = optionLib.OPTION_rws cs |
| 22 | +val () = computeLib.add_thms[ |
| 23 | + CONJUNCT1 ALOOKUP_EQ_FLOOKUP, |
| 24 | + ALOOKUP_def] cs |
| 25 | +val () = computeLib.add_thms |
| 26 | + [term_ok_def,type_ok_def, |
| 27 | + WELLTYPED_CLAUSES,typeof_def, |
| 28 | + CLOSED_def,VFREE_IN_def, |
| 29 | + codomain_def, |
| 30 | + consts_of_upd_def, types_of_upd_def, equation_def, |
| 31 | + hol_ctxt_def,mk_infinity_ctxt_def,mk_select_ctxt_def, |
| 32 | + mk_eta_ctxt_def,mk_bool_ctxt_def,init_ctxt_def] cs |
| 33 | +val () = computeLib.add_datatype_info cs (valOf(TypeBase.fetch``:type``)) |
| 34 | +val () = computeLib.add_datatype_info cs (valOf(TypeBase.fetch``:term``)) |
| 35 | + |
| 36 | +val IND_SUC_def = definition"IND_SUC_def" |
| 37 | +val name = "IND_SUC" |
| 38 | +val tm = term_to_deep(rhs(concl IND_SUC_def)) |
| 39 | +val theory_ok_th = theory_ok_hol_ctxt |
| 40 | + |
| 41 | +val tm_def = IND_SUC_def |
| 42 | + |
| 43 | +want a database with: |
| 44 | + theory_ok (thyof current_ctxt) |
| 45 | + is_std_sig (sigof current_ctxt) |
| 46 | + current_interpretation models (thyof current_ctxt) |
| 47 | + for each constant in current_ctxt: |
| 48 | + lookup constant (sigof current_ctxt) = ... |
| 49 | + lookup constant current_interpretation = ... (connect to outer) ... |
| 50 | + the current_interpretation will include select_fun as a variable |
| 51 | + |
| 52 | +(term_to_cert``ARB``) |
| 53 | +hol_ctxt_def |
| 54 | +show_assums := true |
| 55 | + |
| 56 | +fun mk_ConstDef_th theory_ok_th tm_def = |
| 57 | + let |
| 58 | + val name = tm_def |> concl |> lhs |> dest_const |> fst |
| 59 | + val tm = tm_def |> concl |> rhs |> term_to_deep |
| 60 | + val ctxt = theory_ok_th |> concl |> funpow 5 rand |
| 61 | + val updates_th = ConstDef_updates |
| 62 | + |> SPECL [fromMLstring name,tm,ctxt] |
| 63 | + val goal:goal = ([],fst(dest_imp(concl updates_th))) |
| 64 | + val goal_th = TAC_PROOF(goal, |
| 65 | + conj_tac >- ACCEPT_TAC theory_ok_th >> |
| 66 | + conj_tac >- ( |
| 67 | + CONV_TAC (computeLib.CBV_CONV cs) >> |
| 68 | + simp[exists_equal_thm,exists_REV_ASSOCD_thm] ) >> |
| 69 | + conj_tac >- EVAL_TAC >> |
| 70 | + conj_tac >- ( |
| 71 | + CONV_TAC (computeLib.CBV_CONV cs) >> |
| 72 | + simp[] >> rw[] >> |
| 73 | + rpt( |
| 74 | + Q.PAT_ABBREV_TAC`eq = ((A:string) = B)` >> |
| 75 | + Cases_on`eq`>>fs[markerTheory.Abbrev_def]>> |
| 76 | + rw[]) ) >> |
| 77 | + EVAL_TAC >> simp[]) |
| 78 | + val updates_th = MP updates_th goal_th |
| 79 | + |
| 80 | + in |
| 81 | + end |
| 82 | + |
| 83 | +mk_ConstDef_th theory_ok_hol_ctxt IND_SUC_def |
| 84 | + |
| 85 | +mk_ConstDef_th theory_ok_hol_ctxt "IND_SUC" (term_to_deep(rhs(concl IND_SUC_def))) |
| 86 | +IND_SUC_def |
| 87 | +!the_record |
| 88 | + |
| 89 | +print_find"ConstDef" |
| 90 | + |
| 91 | +val witness_thm = |
| 92 | + ``(thyof (mk_select_ctxt (mk_bool_ctxt init_ctxt)),[]) |- |
| 93 | + Comb |
| 94 | + |
| 95 | +fun mk_TypeDefn_th witness_thm name abs rep = |
| 96 | + let |
| 97 | + val (pred,witness) = dest_Comb(rand(concl witness_thm)) |
| 98 | + |
| 99 | + val ctxt = |
| 100 | +``TypeDefn name |
| 101 | +``(thyof ctxt,[]) |- Comb pred witness`` |
| 102 | +``(TypeDefn name pred abs rep) updates ctxt`` |
| 103 | +fun mk_TypeDefn |
| 104 | +el 5 (CONJUNCTS updates_rules) |
| 105 | + |
0 commit comments