| author | wenzelm | 
| Wed, 28 Feb 2007 22:05:44 +0100 | |
| changeset 22379 | abfcb9899d41 | 
| parent 11668 | 548ba68385a3 | 
| child 27325 | 70e4eb732fa9 | 
| permissions | -rw-r--r-- | 
| 
4349
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents:  
diff
changeset
 | 
1  | 
(* Title: FOL/fologic.ML  | 
| 
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents:  
diff
changeset
 | 
2  | 
ID: $Id$  | 
| 
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents:  
diff
changeset
 | 
3  | 
Author: Lawrence C Paulson  | 
| 
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents:  
diff
changeset
 | 
4  | 
|
| 
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents:  
diff
changeset
 | 
5  | 
Abstract syntax operations for FOL.  | 
| 
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents:  
diff
changeset
 | 
6  | 
*)  | 
| 
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents:  
diff
changeset
 | 
7  | 
|
| 
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents:  
diff
changeset
 | 
8  | 
signature FOLOGIC =  | 
| 
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents:  
diff
changeset
 | 
9  | 
sig  | 
| 6140 | 10  | 
val oT : typ  | 
11  | 
val mk_Trueprop : term -> term  | 
|
12  | 
val dest_Trueprop : term -> term  | 
|
| 9850 | 13  | 
val not : term  | 
| 6140 | 14  | 
val conj : term  | 
15  | 
val disj : term  | 
|
16  | 
val imp : term  | 
|
| 9543 | 17  | 
val iff : term  | 
| 7692 | 18  | 
val mk_conj : term * term -> term  | 
19  | 
val mk_disj : term * term -> term  | 
|
20  | 
val mk_imp : term * term -> term  | 
|
| 6140 | 21  | 
val dest_imp : term -> term*term  | 
| 11668 | 22  | 
val dest_conj : term -> term list  | 
23  | 
val dest_concls : term -> term list  | 
|
| 9543 | 24  | 
val mk_iff : term * term -> term  | 
25  | 
val dest_iff : term -> term*term  | 
|
| 6140 | 26  | 
val all_const : typ -> term  | 
27  | 
val mk_all : term * term -> term  | 
|
28  | 
val exists_const : typ -> term  | 
|
29  | 
val mk_exists : term * term -> term  | 
|
30  | 
val eq_const : typ -> term  | 
|
31  | 
val mk_eq : term * term -> term  | 
|
32  | 
val dest_eq : term -> term*term  | 
|
| 9543 | 33  | 
val mk_binop: string -> term * term -> term  | 
34  | 
val mk_binrel: string -> term * term -> term  | 
|
35  | 
val dest_bin: string -> typ -> term -> term * term  | 
|
| 
4349
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents:  
diff
changeset
 | 
36  | 
end;  | 
| 
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents:  
diff
changeset
 | 
37  | 
|
| 
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents:  
diff
changeset
 | 
38  | 
|
| 
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents:  
diff
changeset
 | 
39  | 
structure FOLogic: FOLOGIC =  | 
| 
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents:  
diff
changeset
 | 
40  | 
struct  | 
| 
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents:  
diff
changeset
 | 
41  | 
|
| 
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents:  
diff
changeset
 | 
42  | 
val oT = Type("o",[]);
 | 
| 
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents:  
diff
changeset
 | 
43  | 
|
| 
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents:  
diff
changeset
 | 
44  | 
val Trueprop = Const("Trueprop", oT-->propT);
 | 
| 
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents:  
diff
changeset
 | 
45  | 
|
| 
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents:  
diff
changeset
 | 
46  | 
fun mk_Trueprop P = Trueprop $ P;  | 
| 
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents:  
diff
changeset
 | 
47  | 
|
| 
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents:  
diff
changeset
 | 
48  | 
fun dest_Trueprop (Const ("Trueprop", _) $ P) = P
 | 
| 
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents:  
diff
changeset
 | 
49  | 
  | dest_Trueprop t = raise TERM ("dest_Trueprop", [t]);
 | 
| 
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents:  
diff
changeset
 | 
50  | 
|
| 
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents:  
diff
changeset
 | 
51  | 
(** Logical constants **)  | 
| 
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents:  
diff
changeset
 | 
52  | 
|
| 9850 | 53  | 
val not = Const ("Not", oT --> oT);
 | 
54  | 
val conj = Const("op &", [oT,oT]--->oT);
 | 
|
55  | 
val disj = Const("op |", [oT,oT]--->oT);
 | 
|
56  | 
val imp = Const("op -->", [oT,oT]--->oT)
 | 
|
57  | 
val iff = Const("op <->", [oT,oT]--->oT);
 | 
|
| 
4349
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents:  
diff
changeset
 | 
58  | 
|
| 7692 | 59  | 
fun mk_conj (t1, t2) = conj $ t1 $ t2  | 
60  | 
and mk_disj (t1, t2) = disj $ t1 $ t2  | 
|
| 9543 | 61  | 
and mk_imp (t1, t2) = imp $ t1 $ t2  | 
62  | 
and mk_iff (t1, t2) = iff $ t1 $ t2;  | 
|
| 7692 | 63  | 
|
| 
4466
 
305390f23734
Better equality handling in Blast_tac, usingd a new variant of hyp_subst_tac
 
paulson 
parents: 
4349 
diff
changeset
 | 
64  | 
fun dest_imp (Const("op -->",_) $ A $ B) = (A, B)
 | 
| 
 
305390f23734
Better equality handling in Blast_tac, usingd a new variant of hyp_subst_tac
 
paulson 
parents: 
4349 
diff
changeset
 | 
65  | 
  | dest_imp  t = raise TERM ("dest_imp", [t]);
 | 
| 
 
305390f23734
Better equality handling in Blast_tac, usingd a new variant of hyp_subst_tac
 
paulson 
parents: 
4349 
diff
changeset
 | 
66  | 
|
| 11668 | 67  | 
fun dest_conj (Const ("op &", _) $ t $ t') = t :: dest_conj t'
 | 
68  | 
| dest_conj t = [t];  | 
|
69  | 
||
70  | 
fun imp_concl_of t = imp_concl_of (#2 (dest_imp t)) handle TERM _ => t;  | 
|
71  | 
val dest_concls = map imp_concl_of o dest_conj o dest_Trueprop;  | 
|
72  | 
||
| 9543 | 73  | 
fun dest_iff (Const("op <->",_) $ A $ B) = (A, B)
 | 
74  | 
  | dest_iff  t = raise TERM ("dest_iff", [t]);
 | 
|
75  | 
||
| 
4349
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents:  
diff
changeset
 | 
76  | 
fun eq_const T = Const ("op =", [T, T] ---> oT);
 | 
| 
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents:  
diff
changeset
 | 
77  | 
fun mk_eq (t, u) = eq_const (fastype_of t) $ t $ u;  | 
| 
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents:  
diff
changeset
 | 
78  | 
|
| 6140 | 79  | 
fun dest_eq (Const ("op =", _) $ lhs $ rhs) = (lhs, rhs)
 | 
80  | 
  | dest_eq t = raise TERM ("dest_eq", [t])
 | 
|
81  | 
||
| 
4349
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents:  
diff
changeset
 | 
82  | 
fun all_const T = Const ("All", [T --> oT] ---> oT);
 | 
| 
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents:  
diff
changeset
 | 
83  | 
fun mk_all (Free(x,T),P) = all_const T $ (absfree (x,T,P));  | 
| 
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents:  
diff
changeset
 | 
84  | 
|
| 
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents:  
diff
changeset
 | 
85  | 
fun exists_const T = Const ("Ex", [T --> oT] ---> oT);
 | 
| 
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents:  
diff
changeset
 | 
86  | 
fun mk_exists (Free(x,T),P) = exists_const T $ (absfree (x,T,P));  | 
| 
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents:  
diff
changeset
 | 
87  | 
|
| 9543 | 88  | 
(* binary oprations and relations *)  | 
89  | 
||
90  | 
fun mk_binop c (t, u) =  | 
|
91  | 
let val T = fastype_of t in  | 
|
92  | 
Const (c, [T, T] ---> T) $ t $ u  | 
|
93  | 
end;  | 
|
94  | 
||
95  | 
fun mk_binrel c (t, u) =  | 
|
96  | 
let val T = fastype_of t in  | 
|
97  | 
Const (c, [T, T] ---> oT) $ t $ u  | 
|
98  | 
end;  | 
|
99  | 
||
100  | 
fun dest_bin c T (tm as Const (c', Type ("fun", [T', _])) $ t $ u) =
 | 
|
101  | 
if c = c' andalso T = T' then (t, u)  | 
|
102  | 
      else raise TERM ("dest_bin " ^ c, [tm])
 | 
|
103  | 
  | dest_bin c _ tm = raise TERM ("dest_bin " ^ c, [tm]);
 | 
|
104  | 
||
105  | 
||
| 
4349
 
50403e5a44c0
Instantiated the one-point-rule quantifier simpprocs for FOL
 
paulson 
parents:  
diff
changeset
 | 
106  | 
end;  |