diff --git a/examples/acl2/ml/Holmakefile b/examples/acl2/ml/Holmakefile index 89b5a63135..245a91fa41 100644 --- a/examples/acl2/ml/Holmakefile +++ b/examples/acl2/ml/Holmakefile @@ -12,7 +12,7 @@ defaxiomsTheory.sig defaxiomsTheory.sml: complex_rationalTheory.uo sexp.uo sexpT ## Since we didn't compile the theory (under polyml) we create the dependency graph first .HOLMK/defaxiomsTheory.sig.d .HOLMK/defaxiomsTheory.sml.d : defaxiomsTheory.sig defaxiomsTheory.sml touch defaxiomsScript.sml && touch defaxiomsTheory.sig defaxiomsTheory.sml && \ - $(HOLMAKE) -r --no_holmakefile && rm defaxiomsScript.sml + $(HOLMAKE) -r --no_hmakefile && rm defaxiomsScript.sml ## We then produce the ui and uo files as 'poly_compile' would defaxiomsTheory.ui : .HOLMK/defaxiomsTheory.sig.d diff --git a/examples/acl2/ml/acl2_packageScript.sml b/examples/acl2/ml/acl2_packageScript.sml index 9c4d4de319..61d27096e6 100644 --- a/examples/acl2/ml/acl2_packageScript.sml +++ b/examples/acl2/ml/acl2_packageScript.sml @@ -21,11 +21,11 @@ quietdec := false; Theory acl2_package Ancestors - list + list string Libs listSyntax pairSyntax stringLib - +val _ = ParseExtras.temp_loose_equality(); (*****************************************************************************) (* ACL2_PACKAGE_ALIST contains a list of triples *) (* *) diff --git a/examples/acl2/ml/complex_rationalScript.sml b/examples/acl2/ml/complex_rationalScript.sml index 217251c8f0..4e4e3aba14 100644 --- a/examples/acl2/ml/complex_rationalScript.sml +++ b/examples/acl2/ml/complex_rationalScript.sml @@ -17,6 +17,7 @@ Ancestors Libs fracLib ratLib +val _ = ParseExtras.temp_loose_equality(); (*****************************************************************************) (* A complex rational x+yi is a pair of rational numbers. *) (* The type ``:complex_rational`` is a datatype isomorphic to *) diff --git a/examples/acl2/ml/hol_defaxiomsScript.sml b/examples/acl2/ml/hol_defaxiomsScript.sml index 4b5485f090..e33f174985 100644 --- a/examples/acl2/ml/hol_defaxiomsScript.sml +++ b/examples/acl2/ml/hol_defaxiomsScript.sml @@ -23,11 +23,12 @@ Ancestors Libs stringLib sexp +(*TODO remove*) +fun ACL2_SIMP_TAC xs = cheat; (* [oracles: DEFUN ACL2::IFF, DISK_THM] [axioms: ] [] |- iff p q = itel [(p,andl [q; t]); (q,nil)] t, *) - val iff_def = acl2Define "ACL2::IFF" `iff p q = itel [(p,andl [q; t]); (q,nil)] t`; @@ -760,8 +761,8 @@ val standard_char_p_def = #"H"; #"I"; #"J"; #"K"; #"L"; #"M"; #"N"; #"O"; #"P"; #"Q"; #"R"; #"S"; #"T"; #"U"; #"V"; #"W"; #"X"; #"Y"; - #"Z"; #"["; #"\\"; #"]"; #"^^"; #"_"; - #"^`"; #"a"; #"b"; #"c"; #"d"; #"e"; + #"Z"; #"["; #"\\"; #"]"; #"^"; #"_"; + #"`"; #"a"; #"b"; #"c"; #"d"; #"e"; #"f"; #"g"; #"h"; #"i"; #"j"; #"k"; #"l"; #"m"; #"n"; #"o"; #"p"; #"q"; #"r"; #"s"; #"t"; #"u"; #"v"; #"w"; @@ -4676,4 +4677,6 @@ val (lexorder_def,lexorder_ind) = (cdr e_slash_d_list) t), *) +(* val _ = export_acl2_theory(); +*) diff --git a/examples/acl2/ml/sexp.sml b/examples/acl2/ml/sexp.sml index b8c8117a89..55321a60e6 100644 --- a/examples/acl2/ml/sexp.sml +++ b/examples/acl2/ml/sexp.sml @@ -67,6 +67,7 @@ open intSyntax pairSyntax listSyntax stringLib numLib; (* ppstream based pretty-printer Parse.pp_term. So a complete solution *) (* for outputting a single term to a given file would be *) (*****************************************************************************) +(* FIXME fun mk_pp_from_out outstream = PP.mk_ppstream { consumer = (fn s => TextIO.output(outstream,s)), linewidth = 80, @@ -80,7 +81,7 @@ in PP.flush_ppstream pps; TextIO.closeOut outstr end; - +*) (*****************************************************************************) (* Swich off warning messages when defining types and constants with *) @@ -730,22 +731,22 @@ fun dest_mlencap (mlpair(_, mlpair(acl2sig,events))) = (*****************************************************************************) fun is_nat tm = is_comb tm andalso - (rator tm = ``nat``) andalso - is_numeral(rand tm); + (aconv (rator tm) ``nat``) andalso + numSyntax.is_numeral(rand tm); (*****************************************************************************) (* Convert ``nat n`` to "n" *) (*****************************************************************************) -fun dest_nat tm = Arbnum.toString(dest_numeral(rand tm)); +fun dest_nat tm = Arbnum.toString(numSyntax.dest_numeral(rand tm)); (*****************************************************************************) (* Test for ``n`` where n is an integer numeral *) (*****************************************************************************) fun is_integer tm = is_comb tm andalso - (if rator tm = ``int_of_num:num->int`` (* $& overloaded on int_of_num *) + (if aconv (rator tm) ``int_of_num:num->int`` (* $& overloaded on int_of_num *) then is_numeral(rand tm) else - if rator tm = ``int_neg:int->int`` (* $~ overloaded on int_neg *) + if aconv (rator tm) ``int_neg:int->int`` (* $~ overloaded on int_neg *) then is_integer(rand tm) else false); @@ -754,7 +755,7 @@ fun is_integer tm = (*****************************************************************************) fun is_int tm = is_comb tm andalso - (rator tm = ``int``) andalso + (aconv (rator tm) ``int``) andalso is_integer(rand tm); (*****************************************************************************) @@ -766,13 +767,13 @@ fun is_int tm = fun dest_integer tm = let val (opr,args) = strip_comb tm in - if opr = ``int_of_num:num->int`` andalso (tl args = []) + if aconv opr ``int_of_num:num->int`` andalso (null (tl args)) then (if is_numeral(hd args) then Arbnum.toString(dest_numeral(hd args)) else (print_term tm; print " is not a non-negative integer numeral\n"; err "dest_integer" "not a non-negative integer numeral")) - else (if opr = ``int_neg:int->int`` andalso (tl args = []) + else (if aconv opr ``int_neg:int->int`` andalso (null (tl args)) then ("-" ^ dest_integer(hd args)) else (print_term tm; print " is not an integer numeral\n"; @@ -819,7 +820,7 @@ fun is_int_string s = fun is_cpx tm = let val (opr,args) = strip_comb tm in - (opr = ``cpx``) + (aconv opr ``cpx``) andalso (length args = 4) andalso is_int_string(dest_integer(el 1 args)) andalso is_num_string(dest_integer(el 2 args)) @@ -932,7 +933,7 @@ fun abbrevMLstring s = (* Version of fromHOLstring that looks up in string_abbrevs. *) (*****************************************************************************) fun abbrevHOLstring c = - rev_assoc c (!string_abbrevs) + op_rev_assoc aconv c (!string_abbrevs) handle HOL_ERR _ => fromHOLstring c; (*****************************************************************************) @@ -1138,7 +1139,7 @@ fun deftm_to_mlsexp_defun tm = (*****************************************************************************) fun def_to_mlsexp_defun th = let val (asl, concl) = dest_thm(SPEC_ALL th) - val _ = if not(asl = []) + val _ = if not(null asl) then(print_thm th; print "\n"; print"should not have any assumptions\n"; err "mk_mlsexp_defthm" "assumptions not allowed") @@ -1677,7 +1678,7 @@ exception fail_for_mapfilter in fun dest_acl2_thm th = let val (asl, conc) = dest_thm(SPEC_ALL th) - val _ = if not(asl = []) + val _ = if not(null asl) then(print_thm th; print "\n"; print"should not have any assumptions\n"; err "dest_acl2_thm" "assumptions not allowed") @@ -1820,7 +1821,7 @@ fun mk_sexp_fun_ty n = (* *) (* where v1,...,vn are the free variables in tm not in vl *) (*****************************************************************************) -fun mk_closed_event vl tm = list_mk_forall(subtract(free_vars tm)vl, tm); +fun mk_closed_event vl tm = list_mk_forall(op_set_diff aconv (free_vars tm)vl, tm); (*****************************************************************************) (* mk_acl2def converts an ML representation of an ACL2 event into an *) @@ -1861,7 +1862,7 @@ fun mk_acl2def d = val tm = list_mk_fun(param_vars, bdy_tm) val ty = type_of tm val unbound_vars = - subtract (free_vars bdy_tm) (name_to_var nam ty :: param_vars) + op_set_diff aconv (free_vars bdy_tm) (name_to_var nam ty :: param_vars) val _ = if null unbound_vars then () else print("Warning: " @@ -1889,7 +1890,7 @@ fun mk_acl2def d = val tm = list_mk_fun(param_vars, ``bool_to_sexp ^quant_tm``) val ty = type_of tm val unbound_vars = - subtract (free_vars quant_tm) (name_to_var nam ty :: param_vars) + op_set_diff aconv (free_vars quant_tm) (name_to_var nam ty :: param_vars) val _ = if null unbound_vars then () else print("Warning: " @@ -1939,7 +1940,7 @@ fun mk_acl2def d = sigll val eventl = map mk_acl2def dl val defunl = mapfilter get_defun_fun eventl - val extended_sig_vars = union sig_vars defunl + val extended_sig_vars = op_union aconv sig_vars defunl val names = map defname eventl val event_tms = map (mk_closed_event extended_sig_vars o spec_all o deftm) eventl @@ -2359,6 +2360,7 @@ fun print_thms_to_defthms name_thm_list file_name = (*****************************************************************************) (* Add theory load time code to restore binding of acl2_simps in theory *) (*****************************************************************************) +(* FIXME fun save_acl2_simps () = adjoin_to_theory {sig_ps = NONE, @@ -2368,10 +2370,12 @@ fun save_acl2_simps () = ("val _ = (sexp.acl2_simps :=" ^" (!sexp.acl2_simps)@(Drule.CONJUNCTS ACL2_SIMPS));")) }; +*) (*****************************************************************************) (* Add theory load time code to restore binding of current_package in theory *) (*****************************************************************************) +(* FIXME fun save_current_package() = adjoin_to_theory {sig_ps = NONE, @@ -2381,10 +2385,12 @@ fun save_current_package() = ("val _ = sexp.set_current_package \"" ^ (!current_package) ^ "\";")) }; +*) (*****************************************************************************) (* Add theory load time code to restore binding of acl2_names in theory. *) (*****************************************************************************) +(* FIXME fun save_acl2_names () = adjoin_to_theory {sig_ps = NONE, @@ -2395,11 +2401,13 @@ fun save_acl2_names () = string_pair_list_to_string(!acl2_names) ^ ";")) }; +*) (*****************************************************************************) (* Add theory load time code to restore binding of string_abbrevs in theory *) (*****************************************************************************) +(* FIXME fun save_string_abbrevs () = adjoin_to_theory {sig_ps = NONE, @@ -2410,11 +2418,13 @@ fun save_string_abbrevs () = string_abbrevs_to_string(!string_abbrevs) ^ ";\n\n")) }; +*) (*****************************************************************************) (* Save the acl2_simps, current_package, acl2_names, acl2_hol_names, *) (* string_abbrevs then export theory. *) (*****************************************************************************) +(* FIXME fun export_acl2_theory () = (save_thm("ACL2_SIMPS", LIST_CONJ(!acl2_simps)); save_acl2_simps(); @@ -2422,6 +2432,7 @@ fun export_acl2_theory () = save_acl2_names(); save_string_abbrevs(); export_theory()); +*) (*****************************************************************************) (* List of events processed. If two events with the same name occur,then the *) @@ -2475,4 +2486,4 @@ val defaxioms_list = map mk_acl2def (!acl2_list_ref); *) -end \ No newline at end of file +end diff --git a/examples/acl2/ml/sexpScript.sml b/examples/acl2/ml/sexpScript.sml index e4a229a21a..767ac71cd1 100644 --- a/examples/acl2/ml/sexpScript.sml +++ b/examples/acl2/ml/sexpScript.sml @@ -25,6 +25,7 @@ Ancestors Libs stringLib sexp +val _ = ParseExtras.temp_loose_equality(); (*****************************************************************************) (* Define s-expressions. *) (*****************************************************************************) @@ -821,6 +822,7 @@ Proof THEN Cases_on `h` THEN Cases_on `r` THEN RW_TAC list_ss [VALID_PKG_TRIPLES_def,VALID_PKG_TRIPLES_AUX_def] + THEN metis_tac[] QED val LOOKUP_IDEMPOTENT_LEMMA = @@ -1230,6 +1232,9 @@ val intern_in_package_of_symbol_def = (*****************************************************************************) (* |= t, where t:sexp, means t is a theorem of ACL2 *) (*****************************************************************************) + +val _ = Parse.remove_rules_for_term combinpp.toplevel_updname + val _ = set_fixity "|=" (Prefix 11); (* Give "|=" weak precedence *) val ACL2_TRUE_def = @@ -1464,7 +1469,7 @@ QED (* 4. The resulting termination conditions should be trivial to prove. *) (*****************************************************************************) -Theorem ite_CONG1: +Theorem ite_CONG1[defncong]: !p q x x' y y'. (p = q) /\ (~(q = nil) ==> (x = x')) /\ ((q = nil) ==> (y = y')) ==> @@ -1473,7 +1478,7 @@ Proof RW_TAC std_ss [ite_def] QED -Theorem ite_CONG2: +Theorem ite_CONG2[defncong]: !p q x x' y y'. (p = q) /\ ((|= q) ==> (x = x')) /\ (~(|= q) ==> (y = y')) ==> @@ -1482,9 +1487,7 @@ Proof RW_TAC std_ss [ite_def,ACL2_TRUE_def,equal_def,EVAL ``t=nil``] QED -val _ = DefnBase.write_congs (ite_CONG1::ite_CONG2::DefnBase.read_congs()); - -Theorem itel_CONG1: +Theorem itel_CONG1[defncong]: !p q x x' l l' y y'. (p = q) /\ @@ -1497,7 +1500,7 @@ Proof RW_TAC std_ss [itel_def,ite_def] QED -Theorem itel_CONG2: +Theorem itel_CONG2[defncong]: !p q x x' l l' y y'. (p = q) /\ @@ -1510,9 +1513,7 @@ Proof RW_TAC std_ss [itel_def,ite_def,ACL2_TRUE_def,equal_def,EVAL ``t=nil``] QED -val _ = DefnBase.write_congs (itel_CONG1::itel_CONG2::DefnBase.read_congs()); - -Theorem andl_CONG: +Theorem andl_CONG[defncong]: !p q x x'. (p = q) /\ (~(p = nil) ==> (x = x')) ==> (andl[p;x] = andl[q;x']) Proof @@ -1520,8 +1521,6 @@ Proof THEN RW_TAC std_ss [andl_def,ite_def] QED -val _ = DefnBase.write_congs (andl_CONG::DefnBase.read_congs()); - Theorem sexp_size_car: !x. ~(consp x = nil) ==> (sexp_size (car x) < sexp_size x) Proof @@ -1570,17 +1569,6 @@ val _ = cdaaar_def,cddaar_def,cdadar_def,cdddar_def,cdaadr_def,cddadr_def,cdaddr_def,cddddr_def, sexp_size_car,sexp_size_cdr, List_def,andl_def]; - -val _ = adjoin_to_theory - {sig_ps = NONE, - struct_ps = - SOME (fn ppstrm => - PP.add_string ppstrm - ("val _ = DefnBase.write_congs" ^ - "(andl_CONG::\ - \ite_CONG1::ite_CONG2::\ - \itel_CONG1::itel_CONG2::\ - \DefnBase.read_congs());\n")) - }; - +(* val _ = export_acl2_theory(); +*) diff --git a/examples/acl2/ml/translateLib.sml b/examples/acl2/ml/translateLib.sml index 7c1de49278..f9e68d4045 100644 --- a/examples/acl2/ml/translateLib.sml +++ b/examples/acl2/ml/translateLib.sml @@ -10,7 +10,9 @@ structure translateLib :> translateLib = struct open Feedback Lib Type Term boolSyntax Thm Drule Tactical Thm_cont Tactic Conv; - +(*TODO remove*) +open boolLib +local open ratTheory in end (*****************************************************************************) (* DOUBLE_MATCH: Like PART_MATCH but matches variables in the term as well *) (*****************************************************************************) @@ -200,7 +202,7 @@ val RAT_CONG_TAC = fun EQUAL_EXISTS_TAC (a,g) = let val (v,body) = dest_exists g val eq_thms = filter is_eq (strip_conj body) - val term = first (curry op= v o lhs) eq_thms + val term = first (aconv v o lhs) eq_thms in EXISTS_TAC (rhs term) (a,g) end; @@ -221,4 +223,4 @@ val FIX_CI_TAC = (STRIP_QUANT_CONV (REWR_CONV boolTheory.AND_IMP_INTRO))))); -end \ No newline at end of file +end diff --git a/examples/acl2/ml/translateScript.sml b/examples/acl2/ml/translateScript.sml index 08e8e318aa..7753166320 100644 --- a/examples/acl2/ml/translateScript.sml +++ b/examples/acl2/ml/translateScript.sml @@ -33,7 +33,7 @@ Ancestors Libs sexp intLib translateLib - +val _ = ParseExtras.temp_loose_equality(); (*****************************************************************************) (* Start new theory "translate" *) (*****************************************************************************) @@ -76,7 +76,8 @@ Theorem sexp_list_ind: Proof REPEAT STRIP_TAC THEN Induct_on `x` THEN TRY (METIS_TAC [sexpTheory.ACL2_TRUE,sexpTheory.consp_def]) THEN - PAT_ASSUM ``!x. ~p ==> q`` (K ALL_TAC) THEN + (* PAT_ASSUM ``!x. ~(|= consp x) ==> q x`` (K ALL_TAC) THEN *) + PRED_ASSUM (is_forall) (K ALL_TAC) THEN REPEAT (FIRST_ASSUM MATCH_MP_TAC) THEN ASM_REWRITE_TAC [consp_def,cdr_def,EVAL ``|= t``] THEN METIS_TAC [] @@ -177,12 +178,12 @@ val pair_thm = save_thm("pair_thm", (Q.SPECL [`f`,`g`,`(a,b)`] pair_def))); Definition pairp_def: - !f g. pairp f g x = + pairp f g x = if (|= consp x) then f (car x) /\ g (cdr x) else F End Definition sexp_to_pair_def: - !f g x. sexp_to_pair f g x = + sexp_to_pair f g x = if (|= consp x) then (f (car x),g (cdr x)) else (f nil,g nil) End @@ -347,9 +348,9 @@ val IS_INT_select = prove( RAT_CONG_TAC THEN PAT_ASSUM ``0i < d`` (fn th => (RULE_ASSUM_TAC (SIMP_RULE std_ss [th,NMR,DNM]))) THEN - PAT_ASSUM ``frac_nmr a = b * c:int`` SUBST_ALL_TAC THEN + PAT_ASSUM ``frac_nmr a = b * c':int`` SUBST_ALL_TAC THEN RULE_ASSUM_TAC (ONCE_REWRITE_RULE [ - CONV_RULE bool_EQ_CONV (AC_CONV(INT_MUL_ASSOC,INT_MUL_COMM) + EQT_ELIM (AC_CONV(INT_MUL_ASSOC,INT_MUL_COMM) ``a * b * c = (a * c) * b:int``)]) THEN IMP_RES_TAC (fst (EQ_IMP_RULE (SPEC_ALL INT_EQ_RMUL))) THEN MP_TAC (SPEC ``x:frac`` FRAC_DNMPOS) THEN ASM_REWRITE_TAC [INT_LT_REFL]); @@ -398,9 +399,9 @@ QED (* Make sure all 'p' functions operate on |= instead of nil or t *) (*****************************************************************************) -val nil_t = CONV_RULE bool_EQ_CONV (EVAL ``~(nil = t)``); -val true_t = CONV_RULE bool_EQ_CONV (EVAL ``|= t``); -val false_f = CONV_RULE bool_EQ_CONV (EVAL ``~(|= nil)``); +val nil_t = EQT_ELIM (EVAL ``~(nil = t)``); +val true_t = EQT_ELIM (EVAL ``|= t``); +val false_f = EQT_ELIM (EVAL ``~(|= nil)``); val nil_nil = prove(``(x = nil) = ~|= x``, EQ_TAC THEN RW_TAC std_ss [false_f] THEN REPEAT (POP_ASSUM MP_TAC THEN @@ -644,9 +645,9 @@ Proof RW_TAC int_ss [ACL2_TRUE] THEN RES_TAC THEN POP_ASSUM (K ALL_TAC) THEN POP_ASSUM MP_TAC THEN RW_TAC int_ss [andl_def,ite_def,GSYM ACL2_TRUE,TRUTH_REWRITES] THEN - `?c. x = int c` by Q.EXISTS_TAC `sexp_to_int x` THEN + `?c. x = int c` by (Q.EXISTS_TAC `sexp_to_int x` THEN ASM_REWRITE_TAC [REWRITE_RULE [o_THM,FUN_EQ_THM] DECENCFIX_INT,ifix_def, - ite_def,TRUTH_REWRITES] THEN + ite_def,TRUTH_REWRITES]) THEN POP_ASSUM SUBST_ALL_TAC THEN FULL_SIMP_TAC int_ss [REWRITE_RULE [o_THM,FUN_EQ_THM] ENCDECMAP_INT] THEN POP_ASSUM MP_TAC THEN @@ -1407,7 +1408,7 @@ Proof QED Theorem PAIR_CASE: - f (pair_case g x) = f ((\(a,b). g a b) x) + f (pair_CASE x g) = f ((\(a,b). g a b) x) Proof Cases_on `x` THEN REWRITE_TAC [TypeBase.case_def_of ``:'a # 'b``] THEN pairLib.GEN_BETA_TAC THEN REWRITE_TAC [] @@ -1488,7 +1489,7 @@ Proof QED Theorem NUM_CASE: - !X a b. f (num_case a b X) = + !X a b. f (num_CASE X a b) = f (if X = 0 then a else b (PRE X)) Proof Cases THEN REWRITE_TAC [TypeBase.case_def_of ``:num``] THEN @@ -1496,7 +1497,7 @@ Proof QED Theorem LIST_CASE: - !l. f (list_case n c l) = + !l. f (list_CASE l n c) = f (if (l = []) then n else c (HD l) (TL l)) Proof Cases THEN RW_TAC arith_ss [NULL,HD,TL] @@ -1609,6 +1610,7 @@ Proof integerTheory.INT_SUB,INT_LE_SUB_LADD,INT_LT_SUB_RADD] QED +(* DUPES Theorem RAT_SUB: rat (a - b) = add (rat a) (unary_minus (rat b)) Proof RW_TAC std_ss [rat_sub_def,frac_sub_def,GSYM RAT_ADD,GSYM RAT_UNARY_MINUS,rat_ainv_def,rat_add_def,frac_ainv_def,RAT_ADD_CONG] @@ -1618,7 +1620,7 @@ Proof Cases_on `a` THEN Cases_on `b` THEN RW_TAC std_ss [COMPLEX_SUB_def,GSYM COM_UNARY_MINUS,GSYM COM_ADD, COMPLEX_NEG_def,COMPLEX_ADD_def,com_0_def,RAT_SUB_LID,rat_0_def,GSYM rat_0,RAT_SUB_ADDAINV] QED - +*) Theorem NAT_SUB_COND: !a b. b <= a ==> (nat (a - b) = add (nat a) (unary_minus (nat b))) Proof RW_TAC int_ss [nat_def,GSYM INT_SUB,nfix_def,ite_def,TRUTH_REWRITES,natp_def,INTEGERP_INT,GSYM INT_EQUAL,GSYM INT_LT,INT_CONG] THEN