This file is indexed.

/usr/share/hol88-2.02.19940316/Library/pair/both2.ml is in hol88-library-source 2.02.19940316-19.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
% --------------------------------------------------------------------- %
% 		Copyright (c) Jim Grundy 1992				%
%               All rights reserved                                     %
%									%
% Jim Grundy, hereafter referred to as `the Author', retains the	%
% copyright and all other legal rights to the Software contained in	%
% this file, hereafter referred to as `the Software'.			%
% 									%
% The Software is made available free of charge on an `as is' basis.	%
% No guarantee, either express or implied, of maintenance, reliability	%
% or suitability for any purpose is made by the Author.			%
% 									%
% The user is granted the right to make personal or internal use	%
% of the Software provided that both:					%
% 1. The Software is not used for commercial gain.			%
% 2. The user shall not hold the Author liable for any consequences	%
%    arising from use of the Software.					%
% 									%
% The user is granted the right to further distribute the Software	%
% provided that both:							%
% 1. The Software and this statement of rights is not modified.		%
% 2. The Software does not form part or the whole of a system 		%
%    distributed for commercial gain.					%
% 									%
% The user is granted the right to modify the Software for personal or	%
% internal use provided that all of the following conditions are	%
% observed:								%
% 1. The user does not distribute the modified software. 		%
% 2. The modified software is not used for commercial gain.		%
% 3. The Author retains all rights to the modified software.		%
%									%
% Anyone seeking a licence to use this software for commercial purposes	%
% is invited to contact the Author.					%
% --------------------------------------------------------------------- %
% CONTENTS: Functions which are common to both paried universal and	%
%           existential quantifications and which rely on more		%
%           primitive functions from all.ml and exi.ml.			%
% --------------------------------------------------------------------- %
%$Id: both2.ml,v 3.1 1993/12/07 14:42:10 jg Exp $%

% ------------------------------------------------------------------------- %
% Paired stiping tactics, same as basic ones, but they use PGEN_TAC         %
% and PCHOOSE_THEN rather than GEN_TAC and CHOOSE_THEN                      %
% ------------------------------------------------------------------------- %

let PSTRIP_THM_THEN =
    FIRST_TCL [CONJUNCTS_THEN; DISJ_CASES_THEN; PCHOOSE_THEN];;

let PSTRIP_ASSUME_TAC =
    (REPEAT_TCL PSTRIP_THM_THEN) CHECK_ASSUME_TAC;;

let PSTRUCT_CASES_TAC =
    REPEAT_TCL PSTRIP_THM_THEN
	 (\th. SUBST1_TAC th  ORELSE  ASSUME_TAC th);;

let PSTRIP_GOAL_THEN ttac = FIRST [PGEN_TAC; CONJ_TAC; DISCH_THEN ttac];;

let FILTER_PSTRIP_THEN ttac tm =
    FIRST [
	FILTER_PGEN_TAC tm;
	FILTER_DISCH_THEN ttac tm;
	CONJ_TAC ];;

let PSTRIP_TAC = PSTRIP_GOAL_THEN PSTRIP_ASSUME_TAC;;

let FILTER_PSTRIP_TAC = FILTER_PSTRIP_THEN PSTRIP_ASSUME_TAC;;

% ------------------------------------------------------------------------- %
%  A |- !p. (f p) = (g p)                                                   %
% ------------------------ PEXT                                             %
%       A |- f = g                                                          %
% ------------------------------------------------------------------------- %

let PEXT th =
    (let (p,_) = dest_pforall (concl th) in
    let p' = pvariant (thm_frees th) p in
    let th1 = PSPEC p' th in
    let th2 = PABS p' th1 in
    let th3 = (CONV_RULE (RATOR_CONV (RAND_CONV PETA_CONV))) th2 in
	(CONV_RULE (RAND_CONV PETA_CONV)) th3
    ) ? failwith `PEXT`;;

% ------------------------------------------------------------------------- %
% P_FUN_EQ_CONV "p" "f = g" = |- (f = g) = (!p. (f p) = (g p))              %
% ------------------------------------------------------------------------- %

let P_FUN_EQ_CONV =
    let gpty = ":*" in
    let grange = ":**" in
    let gfty = ":*->**" in
    let gf = genvar gfty in
    let gg = genvar gfty in
    let gp = genvar gpty in
    let imp1 = DISCH_ALL (GEN gp (AP_THM (ASSUME (mk_eq(gf,gg))) gp)) in
    let imp2 =
	DISCH_ALL
	    (EXT (ASSUME (mk_forall(gp, mk_eq(mk_comb(gf,gp),mk_comb(gg,gp))))))
    in
    let ext_thm = (IMP_ANTISYM_RULE imp1 imp2) in
	\p tm.
	    let (f,g) = dest_eq tm in
	    let fty = type_of f 
	    and pty = type_of p in
	    let gfinst = mk_var(fst (dest_var gf), fty)
	    and gginst = mk_var(fst (dest_var gg), fty) in
	    let range = hd (tl(snd(dest_type fty))) in
	    let th =
		INST_TY_TERM
		    ([(f,gfinst);(g,gginst)],
		     [(pty,gpty);(range,grange)])
		    ext_thm in
		(CONV_RULE (RAND_CONV (RAND_CONV (PALPHA_CONV p)))) th ;;

% ------------------------------------------------------------------------- %
%      A |- !p. t = u                                                       %
% ------------------------ MK_PABS                                          %
%  A |- (\p. t) = (\p. u)                                                   %
% ------------------------------------------------------------------------- %

let MK_PABS th =
    (let (p,_) = dest_pforall (concl th) in
    let th1 = (CONV_RULE (RAND_CONV (PABS_CONV (RATOR_CONV (RAND_CONV
		(UNPBETA_CONV p)))))) th in
    let th2 = (CONV_RULE (RAND_CONV (PABS_CONV (RAND_CONV
		(UNPBETA_CONV p))))) th1 in
    let th3 = PEXT th2 in
    let th4 = (CONV_RULE (RATOR_CONV (RAND_CONV (PALPHA_CONV p)))) th3 in
	(CONV_RULE (RAND_CONV (PALPHA_CONV p))) th4
    ) ? failwith `MK_PABS`;;

% ------------------------------------------------------------------------- %
%  A |- !p. t p = u                                                         %
% ------------------ HALF_MK_PABS                                           %
%  A |- t = (\p. u)                                                         %
% ------------------------------------------------------------------------- %

let HALF_MK_PABS th = 
    (let (p,_) = dest_pforall (concl th) in
    let th1 = (CONV_RULE (RAND_CONV (PABS_CONV (RAND_CONV 
		(UNPBETA_CONV p))))) th in
    let th2 = PEXT th1 in 
	(CONV_RULE (RAND_CONV (PALPHA_CONV p))) th2
    ) ? failwith `HALF_MK_PABS` ;;

% ------------------------------------------------------------------------- %
%      A |- !p. t = u                                                       %
% ------------------------ MK_PFORALL                                       %
%  A |- (!p. t) = (!p. u)                                                   %
% ------------------------------------------------------------------------- %
let MK_PFORALL th =
    (let (p,_) = dest_pforall (concl th) in
    AP_TERM
    (mk_const
	(`!`, mk_type(`fun`, [mk_type(`fun`, [type_of p; bool_ty]); bool_ty])))
    (MK_PABS th)) ? failwith `MK_PFORALL` ;;

% ------------------------------------------------------------------------- %
%      A |- !p. t = u                                                       %
% ------------------------ MK_PEXISTS                                       %
%  A |- (?p. t) = (?p. u)                                                   %
% ------------------------------------------------------------------------- %
let MK_PEXISTS th =
    (let (p,_) = dest_pforall (concl th) in
    AP_TERM
    (mk_const
	(`?`, mk_type(`fun`, [mk_type(`fun`, [type_of p; bool_ty]); bool_ty])))
    (MK_PABS th)) ? failwith `MK_PEXISTS` ;;

% ------------------------------------------------------------------------- %
%      A |- !p. t = u                                                       %
% ------------------------ MK_PSELECT                                       %
%  A |- (@p. t) = (@p. u)                                                   %
% ------------------------------------------------------------------------- %
let MK_PEXISTS th =
    (let (p,_) = dest_pforall (concl th) in
     let pty = type_of p in
    AP_TERM
    (mk_const
	(`@`, mk_type(`fun`, [mk_type(`fun`, [pty; bool_ty]); pty])))
    (MK_PABS th)) ? failwith `MK_PSELECT` ;;

% ------------------------------------------------------------------------- %
%       A |- t = u                                                          %
% ------------------------ PFORALL_EQ "p"                                   %
%  A |- (!p. t) = (!p. u)                                                   %
% ------------------------------------------------------------------------- %

let PFORALL_EQ p th =
    (let pty = type_of p in
	AP_TERM
	    (mk_const
	    (`!`, mk_type(`fun`, [mk_type(`fun`, [pty; bool_ty ]); bool_ty])))
	(PABS p th)) ? failwith `PFORALL_EQ` ;;

% ------------------------------------------------------------------------- %
%       A |- t = u                                                          %
% ------------------------ PEXISTS_EQ "p"                                   %
%  A |- (?p. t) = (?p. u)                                                   %
% ------------------------------------------------------------------------- %

let PEXISTS_EQ p th =
    (let pty = type_of p in
	AP_TERM
	    (mk_const
	    (`?`, mk_type(`fun`, [mk_type(`fun`, [pty; bool_ty ]); bool_ty])))
	(PABS p th)) ? failwith `PEXISTS_EQ` ;;

% ------------------------------------------------------------------------- %
%       A |- t = u                                                          %
% ------------------------ PSELECT_EQ "p"                                   %
%  A |- (@p. t) = (@p. u)                                                   %
% ------------------------------------------------------------------------- %

let PSELECT_EQ p th =
    (let pty = type_of p in
	AP_TERM
	    (mk_const
	    (`@`, mk_type(`fun`, [mk_type(`fun`, [pty; bool_ty ]); pty])))
	(PABS p th)) ? failwith `PSELECT_EQ` ;;

% ------------------------------------------------------------------------- %
%                A |- t = u                                                 %
% ---------------------------------------- LIST_MK_PFORALL [p1;...pn]       %
%  A |- (!p1 ... pn. t) = (!p1 ... pn. u)                                   %
% ------------------------------------------------------------------------- %

let LIST_MK_PFORALL = itlist PFORALL_EQ ;;

% ------------------------------------------------------------------------- %
%                A |- t = u                                                 %
% ---------------------------------------- LIST_MK_PEXISTS [p1;...pn]       %
%  A |- (?p1 ... pn. t) = (?p1 ... pn. u)                                   %
% ------------------------------------------------------------------------- %

let LIST_MK_PEXISTS = itlist PEXISTS_EQ ;;
		
% ------------------------------------------------------------------------- %
%         A |- P ==> Q                                                      %
% -------------------------- EXISTS_IMP "p"                                 %
%  A |- (?p. P) ==> (?p. Q)                                                 %
% ------------------------------------------------------------------------- %

let PEXISTS_IMP p th =
    (let (a,c) = dest_imp (concl th) in
    let th1 = PEXISTS (mk_pexists(p,c),p) (UNDISCH th) in
    let asm = mk_pexists(p,a) in
    let th2 = DISCH asm (PCHOOSE (p, ASSUME asm) th1) in
	(CONV_RULE (RAND_CONV (GEN_PALPHA_CONV p))) th2 
    ) ? failwith `PEXISTS_IMP`;;

% ------------------------------------------------------------------------- %
% SWAP_PFORALL_CONV "!p q. t" = (|- (!p q. t) = (!q p. t))                  %
% ------------------------------------------------------------------------- %

let SWAP_PFORALL_CONV pqt =
    (let (p,qt) = dest_pforall pqt in
    let (q,t) = dest_pforall qt in
    let p' = genlike p in
    let q' = genlike q in
    let th1 = GEN_PALPHA_CONV p' pqt in
    let th2 = CONV_RULE
		(RAND_CONV (RAND_CONV (PABS_CONV (GEN_PALPHA_CONV q')))) th1 in
    let th3 = CONV_RULE (RAND_CONV (GEN_PALPHA_CONV q)) th2 in
	CONV_RULE
	    (RAND_CONV (RAND_CONV (PABS_CONV (GEN_PALPHA_CONV p)))) th3
    ) ? failwith `SWAP_PFORALL_CONV`;;

% ------------------------------------------------------------------------- %
% SWAP_PEXISTS_CONV "?p q. t" = (|- (?p q. t) = (?q p. t))                  %
% ------------------------------------------------------------------------- %

let SWAP_PEXISTS_CONV pqt =
    (let (p,qt) = dest_pexists pqt in
    let (q,t) = dest_pexists qt in
    let p' = genlike p in
    let q' = genlike q in
    let th1 = GEN_PALPHA_CONV p' pqt in
    let th2 = CONV_RULE
		(RAND_CONV (RAND_CONV (PABS_CONV (GEN_PALPHA_CONV q')))) th1 in
    let th3 = CONV_RULE (RAND_CONV (GEN_PALPHA_CONV q)) th2 in
	CONV_RULE
	    (RAND_CONV (RAND_CONV (PABS_CONV (GEN_PALPHA_CONV p)))) th3
    ) ? failwith `SWAP_PEXISTS_CONV`;;


% --------------------------------------------------------------------- %
% PART_PMATCH : just like PART_MATCH but doesn't mind leading paird q.s	%
% --------------------------------------------------------------------- %

let PART_PMATCH partfn th =
    let pth = GPSPEC (GSPEC (GEN_ALL th))  in
    let pat = partfn (concl pth) in
    let matchfn = match pat in
    \tm. INST_TY_TERM (matchfn tm) pth;;

% --------------------------------------------------------------------- %
%  A ?- !v1...vi. t'                                                    %
% ================== MATCH_MP_TAC (A' |- !x1...xn. s ==> !y1...tm. t)	%
%  A ?- ?z1...zp. s'                                                    %
% where z1, ..., zp are (type instances of) those variables among	%
% x1, ..., xn that do not occur free in t.				%
% --------------------------------------------------------------------- %

let PMATCH_MP_TAC : thm_tactic =
    let efn p (tm,th) = let ntm = mk_pexists(p,tm) in
        (ntm, PCHOOSE (p, ASSUME ntm) th)
    in
    \thm.
	let (tps,(ant,(cps,con))) =
	    ((I # ((I # strip_forall) o dest_imp)) o strip_pforall o concl) thm
	    ? failwith `MATCH_MP_TAC: not an implication` in
        let th1 = PSPECL cps (UNDISCH (PSPECL tps thm)) in
        let eps = filter (\p. not (occs_in p con)) tps in 
        let th2 = uncurry DISCH (itlist efn eps (ant,th1)) in
        \(A,g).
	    let (gps,gl) = strip_pforall g in
            let ins = match con gl ? failwith `PMATCH_MP_TAC: no match` in
            let ith = INST_TY_TERM ins th2 in
            let newg = fst(dest_imp(concl ith)) in
            let gth = PGENL gps (UNDISCH ith) ?
                           failwith `PMATCH_MP_TAC: generalized pair(s)` in
		([(A,newg)], \[th]. PROVE_HYP th gth);;

% --------------------------------------------------------------------- %
%  A1 |- !x1..xn. t1 ==> t2   A2 |- t1'            			%
% --------------------------------------  PMATCH_MP			%
%        A1 u A2 |- !xa..xk. t2'					%
% --------------------------------------------------------------------- %

let PMATCH_MP =
    letrec variants as vs =
	if null vs then
	    []
	else
	    let (h.t) = vs in
	    let h' = variant (as@(filter (\e. not (e = h)) t)) h in
	      (h',h).(variants (h'.as) t) in
    let frev_assoc e2 l = (fst (rev_assoc e2 l)) ? e2 
    in
    \ith. 
    let t = (fst o dest_imp o snd o strip_pforall o concl) ith
	    ? failwith `PMATCH_MP: not an implication` in
    \th.
    (let (B,t') = dest_thm th in
    let ty_inst = snd (match t t') in
    let ith_ = INST_TYPE ty_inst ith in
    let (A_, forall_ps_t_imp_u_) = dest_thm ith_ in
    let (ps_,t_imp_u_) = strip_pforall forall_ps_t_imp_u_ in
    let (t_,u_) = dest_imp (t_imp_u_) in
    let pvs = freesl ps_ in
    let A_vs = freesl A_ in
    let B_vs = freesl B in
    let tm_inst = fst (match t_ t') in
    let (match_vs, unmatch_vs) = partition (C free_in t_) (frees u_) in
    let rename = subtract unmatch_vs (subtract A_vs pvs) in
    let new_vs = freesl (map (C frev_assoc tm_inst) match_vs) in
    let renaming = variants (new_vs@A_vs@B_vs) rename in
    let (specs,insts) = partition (C mem (freesl pvs) o snd)
	    (renaming@tm_inst) in
    let spec_list = map (subst specs) ps_ in
    let mp_th = MP (PSPECL spec_list (INST insts ith_)) th in
    let gen_ps = (filter (\p. null (subtract (rip_pair p) rename)) ps_) in
    let qs = map (subst renaming) gen_ps
    in
	PGENL qs mp_th
    ) ? failwith `PMATCH_MP: can't instantiate theorem`;;