58 Scan.finite Symbol.stopper |
59 Scan.finite Symbol.stopper |
59 (Scan.error (!! (fn _ => raise SYNTAX "malformed TPTP input") |
60 (Scan.error (!! (fn _ => raise SYNTAX "malformed TPTP input") |
60 parse_problem)) |
61 parse_problem)) |
61 o tptp_explode |
62 o tptp_explode |
62 |
63 |
63 val boolT = @{typ bool} |
64 val iota_T = @{typ iota} |
64 val iotaT = @{typ iota} |
65 val quant_T = (iota_T --> bool_T) --> bool_T |
65 val quantT = (iotaT --> boolT) --> boolT |
|
66 |
66 |
67 fun is_variable s = Char.isUpper (String.sub (s, 0)) |
67 fun is_variable s = Char.isUpper (String.sub (s, 0)) |
68 |
68 |
69 fun hol_term_from_fo_term res_T (ATerm (x, us)) = |
69 fun hol_term_from_fo_term res_T (ATerm (x, us)) = |
70 let val ts = map (hol_term_from_fo_term iotaT) us in |
70 let val ts = map (hol_term_from_fo_term iota_T) us in |
71 list_comb ((case x of |
71 list_comb ((case x of |
72 "$true" => @{const_name True} |
72 "$true" => @{const_name True} |
73 | "$false" => @{const_name False} |
73 | "$false" => @{const_name False} |
74 | "=" => @{const_name HOL.eq} |
74 | "=" => @{const_name HOL.eq} |
75 | "equal" => @{const_name HOL.eq} |
75 | "equal" => @{const_name HOL.eq} |
80 fun hol_prop_from_formula phi = |
80 fun hol_prop_from_formula phi = |
81 case phi of |
81 case phi of |
82 AQuant (_, [], phi') => hol_prop_from_formula phi' |
82 AQuant (_, [], phi') => hol_prop_from_formula phi' |
83 | AQuant (q, (x, _) :: xs, phi') => |
83 | AQuant (q, (x, _) :: xs, phi') => |
84 Const (case q of AForall => @{const_name All} | AExists => @{const_name Ex}, |
84 Const (case q of AForall => @{const_name All} | AExists => @{const_name Ex}, |
85 quantT) |
85 quant_T) |
86 $ lambda (Free (x, iotaT)) (hol_prop_from_formula (AQuant (q, xs, phi'))) |
86 $ lambda (Free (x, iota_T)) (hol_prop_from_formula (AQuant (q, xs, phi'))) |
87 | AConn (ANot, [u']) => HOLogic.mk_not (hol_prop_from_formula u') |
87 | AConn (ANot, [u']) => HOLogic.mk_not (hol_prop_from_formula u') |
88 | AConn (c, [u1, u2]) => |
88 | AConn (c, [u1, u2]) => |
89 pairself hol_prop_from_formula (u1, u2) |
89 pairself hol_prop_from_formula (u1, u2) |
90 |> (case c of |
90 |> (case c of |
91 AAnd => HOLogic.mk_conj |
91 AAnd => HOLogic.mk_conj |
92 | AOr => HOLogic.mk_disj |
92 | AOr => HOLogic.mk_disj |
93 | AImplies => HOLogic.mk_imp |
93 | AImplies => HOLogic.mk_imp |
94 | AIff => HOLogic.mk_eq |
94 | AIff => HOLogic.mk_eq |
95 | ANot => raise Fail "binary \"ANot\"") |
95 | ANot => raise Fail "binary \"ANot\"") |
96 | AConn _ => raise Fail "malformed AConn" |
96 | AConn _ => raise Fail "malformed AConn" |
97 | AAtom u => hol_term_from_fo_term boolT u |
97 | AAtom u => hol_term_from_fo_term bool_T u |
98 |
98 |
99 fun mk_all x t = Const (@{const_name All}, quantT) $ lambda x t |
99 fun mk_all x t = Const (@{const_name All}, quant_T) $ lambda x t |
100 |
100 |
101 fun close_hol_prop t = fold (mk_all o Free) (Term.add_frees t []) t |
101 fun close_hol_prop t = fold (mk_all o Free) (Term.add_frees t []) t |
102 |
102 |
103 fun pick_nits_in_fof_file file_name = |
103 fun pick_nits_in_fof_file file_name = |
104 case parse_tptp_problem (File.read (Path.explode file_name)) of |
104 case parse_tptp_problem (File.read (Path.explode file_name)) of |