1 (**************************************************************************)
4 (* ||A|| A project by Andrea Asperti *)
6 (* ||I|| Developers: *)
7 (* ||T|| The HELM team. *)
8 (* ||A|| http://helm.cs.unibo.it *)
10 (* \ / This file is distributed under the terms of the *)
11 (* v GNU General Public License Version 2 *)
13 (**************************************************************************)
15 (* ********************************************************************** *)
16 (* Progetto FreeScale *)
18 (* Sviluppato da: Ing. Cosimo Oliboni, oliboni@cs.unibo.it *)
19 (* Ultima modifica: 05/08/2009 *)
21 (* ********************************************************************** *)
23 include "common/string_lemmas.ma".
25 nlet rec nmember_list (T:Type) (elem:T) (f:T → T → bool) (l:list T) on l ≝
28 | cons h t ⇒ match f elem h with
29 [ true ⇒ false | false ⇒ nmember_list T elem f t ]
32 (* elem presente una ed una sola volta in l *)
33 nlet rec member_list (T:Type) (elem:T) (f:T → T → bool) (l:list T) on l ≝
36 | cons h t ⇒ match f elem h with
37 [ true ⇒ nmember_list T elem f t | false ⇒ member_list T elem f t ]
40 (* tutti gli atomi dell'universo che poi saranno raggruppati in sottouniversi *)
41 ninductive UN : Type ≝
42 (* quaternari[4] 1-4 *)
58 (* esadecimali[16] 13-28 *)
76 (* bitrigesimali[32] 29-60 *)
110 (* ascii[63] 61-123 *)
175 (* opcode[91] 124-214 *)
269 (* funzione di uguaglianza sugli atomi *)
272 [ uq0 ⇒ match u2 with [ uq0 ⇒ true | _ ⇒ false ]
273 | uq1 ⇒ match u2 with [ uq1 ⇒ true | _ ⇒ false ]
274 | uq2 ⇒ match u2 with [ uq2 ⇒ true | _ ⇒ false ]
275 | uq3 ⇒ match u2 with [ uq3 ⇒ true | _ ⇒ false ]
277 | uo0 ⇒ match u2 with [ uo0 ⇒ true | _ ⇒ false ]
278 | uo1 ⇒ match u2 with [ uo1 ⇒ true | _ ⇒ false ]
279 | uo2 ⇒ match u2 with [ uo2 ⇒ true | _ ⇒ false ]
280 | uo3 ⇒ match u2 with [ uo3 ⇒ true | _ ⇒ false ]
281 | uo4 ⇒ match u2 with [ uo4 ⇒ true | _ ⇒ false ]
282 | uo5 ⇒ match u2 with [ uo5 ⇒ true | _ ⇒ false ]
283 | uo6 ⇒ match u2 with [ uo6 ⇒ true | _ ⇒ false ]
284 | uo7 ⇒ match u2 with [ uo7 ⇒ true | _ ⇒ false ]
286 | ux0 ⇒ match u2 with [ ux0 ⇒ true | _ ⇒ false ]
287 | ux1 ⇒ match u2 with [ ux1 ⇒ true | _ ⇒ false ]
288 | ux2 ⇒ match u2 with [ ux2 ⇒ true | _ ⇒ false ]
289 | ux3 ⇒ match u2 with [ ux3 ⇒ true | _ ⇒ false ]
290 | ux4 ⇒ match u2 with [ ux4 ⇒ true | _ ⇒ false ]
291 | ux5 ⇒ match u2 with [ ux5 ⇒ true | _ ⇒ false ]
292 | ux6 ⇒ match u2 with [ ux6 ⇒ true | _ ⇒ false ]
293 | ux7 ⇒ match u2 with [ ux7 ⇒ true | _ ⇒ false ]
294 | ux8 ⇒ match u2 with [ ux8 ⇒ true | _ ⇒ false ]
295 | ux9 ⇒ match u2 with [ ux9 ⇒ true | _ ⇒ false ]
296 | uxA ⇒ match u2 with [ uxA ⇒ true | _ ⇒ false ]
297 | uxB ⇒ match u2 with [ uxB ⇒ true | _ ⇒ false ]
298 | uxC ⇒ match u2 with [ uxC ⇒ true | _ ⇒ false ]
299 | uxD ⇒ match u2 with [ uxD ⇒ true | _ ⇒ false ]
300 | uxE ⇒ match u2 with [ uxE ⇒ true | _ ⇒ false ]
301 | uxF ⇒ match u2 with [ uxF ⇒ true | _ ⇒ false ]
303 | ut00 ⇒ match u2 with [ ut00 ⇒ true | _ ⇒ false ]
304 | ut01 ⇒ match u2 with [ ut01 ⇒ true | _ ⇒ false ]
305 | ut02 ⇒ match u2 with [ ut02 ⇒ true | _ ⇒ false ]
306 | ut03 ⇒ match u2 with [ ut03 ⇒ true | _ ⇒ false ]
307 | ut04 ⇒ match u2 with [ ut04 ⇒ true | _ ⇒ false ]
308 | ut05 ⇒ match u2 with [ ut05 ⇒ true | _ ⇒ false ]
309 | ut06 ⇒ match u2 with [ ut06 ⇒ true | _ ⇒ false ]
310 | ut07 ⇒ match u2 with [ ut07 ⇒ true | _ ⇒ false ]
311 | ut08 ⇒ match u2 with [ ut08 ⇒ true | _ ⇒ false ]
312 | ut09 ⇒ match u2 with [ ut09 ⇒ true | _ ⇒ false ]
313 | ut0A ⇒ match u2 with [ ut0A ⇒ true | _ ⇒ false ]
314 | ut0B ⇒ match u2 with [ ut0B ⇒ true | _ ⇒ false ]
315 | ut0C ⇒ match u2 with [ ut0C ⇒ true | _ ⇒ false ]
316 | ut0D ⇒ match u2 with [ ut0D ⇒ true | _ ⇒ false ]
317 | ut0E ⇒ match u2 with [ ut0E ⇒ true | _ ⇒ false ]
318 | ut0F ⇒ match u2 with [ ut0F ⇒ true | _ ⇒ false ]
319 | ut10 ⇒ match u2 with [ ut10 ⇒ true | _ ⇒ false ]
320 | ut11 ⇒ match u2 with [ ut11 ⇒ true | _ ⇒ false ]
321 | ut12 ⇒ match u2 with [ ut12 ⇒ true | _ ⇒ false ]
322 | ut13 ⇒ match u2 with [ ut13 ⇒ true | _ ⇒ false ]
323 | ut14 ⇒ match u2 with [ ut14 ⇒ true | _ ⇒ false ]
324 | ut15 ⇒ match u2 with [ ut15 ⇒ true | _ ⇒ false ]
325 | ut16 ⇒ match u2 with [ ut16 ⇒ true | _ ⇒ false ]
326 | ut17 ⇒ match u2 with [ ut17 ⇒ true | _ ⇒ false ]
327 | ut18 ⇒ match u2 with [ ut18 ⇒ true | _ ⇒ false ]
328 | ut19 ⇒ match u2 with [ ut19 ⇒ true | _ ⇒ false ]
329 | ut1A ⇒ match u2 with [ ut1A ⇒ true | _ ⇒ false ]
330 | ut1B ⇒ match u2 with [ ut1B ⇒ true | _ ⇒ false ]
331 | ut1C ⇒ match u2 with [ ut1C ⇒ true | _ ⇒ false ]
332 | ut1D ⇒ match u2 with [ ut1D ⇒ true | _ ⇒ false ]
333 | ut1E ⇒ match u2 with [ ut1E ⇒ true | _ ⇒ false ]
334 | ut1F ⇒ match u2 with [ ut1F ⇒ true | _ ⇒ false ]
336 | uch_0 ⇒ match u2 with [ uch_0 ⇒ true | _ ⇒ false ]
337 | uch_1 ⇒ match u2 with [ uch_1 ⇒ true | _ ⇒ false ]
338 | uch_2 ⇒ match u2 with [ uch_2 ⇒ true | _ ⇒ false ]
339 | uch_3 ⇒ match u2 with [ uch_3 ⇒ true | _ ⇒ false ]
340 | uch_4 ⇒ match u2 with [ uch_4 ⇒ true | _ ⇒ false ]
341 | uch_5 ⇒ match u2 with [ uch_5 ⇒ true | _ ⇒ false ]
342 | uch_6 ⇒ match u2 with [ uch_6 ⇒ true | _ ⇒ false ]
343 | uch_7 ⇒ match u2 with [ uch_7 ⇒ true | _ ⇒ false ]
344 | uch_8 ⇒ match u2 with [ uch_8 ⇒ true | _ ⇒ false ]
345 | uch_9 ⇒ match u2 with [ uch_9 ⇒ true | _ ⇒ false ]
346 | uch__ ⇒ match u2 with [ uch__ ⇒ true | _ ⇒ false ]
347 | uch_A ⇒ match u2 with [ uch_A ⇒ true | _ ⇒ false ]
348 | uch_B ⇒ match u2 with [ uch_B ⇒ true | _ ⇒ false ]
349 | uch_C ⇒ match u2 with [ uch_C ⇒ true | _ ⇒ false ]
350 | uch_D ⇒ match u2 with [ uch_D ⇒ true | _ ⇒ false ]
351 | uch_E ⇒ match u2 with [ uch_E ⇒ true | _ ⇒ false ]
352 | uch_F ⇒ match u2 with [ uch_F ⇒ true | _ ⇒ false ]
353 | uch_G ⇒ match u2 with [ uch_G ⇒ true | _ ⇒ false ]
354 | uch_H ⇒ match u2 with [ uch_H ⇒ true | _ ⇒ false ]
355 | uch_I ⇒ match u2 with [ uch_I ⇒ true | _ ⇒ false ]
356 | uch_J ⇒ match u2 with [ uch_J ⇒ true | _ ⇒ false ]
357 | uch_K ⇒ match u2 with [ uch_K ⇒ true | _ ⇒ false ]
358 | uch_L ⇒ match u2 with [ uch_L ⇒ true | _ ⇒ false ]
359 | uch_M ⇒ match u2 with [ uch_M ⇒ true | _ ⇒ false ]
360 | uch_N ⇒ match u2 with [ uch_N ⇒ true | _ ⇒ false ]
361 | uch_O ⇒ match u2 with [ uch_O ⇒ true | _ ⇒ false ]
362 | uch_P ⇒ match u2 with [ uch_P ⇒ true | _ ⇒ false ]
363 | uch_Q ⇒ match u2 with [ uch_Q ⇒ true | _ ⇒ false ]
364 | uch_R ⇒ match u2 with [ uch_R ⇒ true | _ ⇒ false ]
365 | uch_S ⇒ match u2 with [ uch_S ⇒ true | _ ⇒ false ]
366 | uch_T ⇒ match u2 with [ uch_T ⇒ true | _ ⇒ false ]
367 | uch_U ⇒ match u2 with [ uch_U ⇒ true | _ ⇒ false ]
368 | uch_V ⇒ match u2 with [ uch_V ⇒ true | _ ⇒ false ]
369 | uch_W ⇒ match u2 with [ uch_W ⇒ true | _ ⇒ false ]
370 | uch_X ⇒ match u2 with [ uch_X ⇒ true | _ ⇒ false ]
371 | uch_Y ⇒ match u2 with [ uch_Y ⇒ true | _ ⇒ false ]
372 | uch_Z ⇒ match u2 with [ uch_Z ⇒ true | _ ⇒ false ]
373 | uch_a ⇒ match u2 with [ uch_a ⇒ true | _ ⇒ false ]
374 | uch_b ⇒ match u2 with [ uch_b ⇒ true | _ ⇒ false ]
375 | uch_c ⇒ match u2 with [ uch_c ⇒ true | _ ⇒ false ]
376 | uch_d ⇒ match u2 with [ uch_d ⇒ true | _ ⇒ false ]
377 | uch_e ⇒ match u2 with [ uch_e ⇒ true | _ ⇒ false ]
378 | uch_f ⇒ match u2 with [ uch_f ⇒ true | _ ⇒ false ]
379 | uch_g ⇒ match u2 with [ uch_g ⇒ true | _ ⇒ false ]
380 | uch_h ⇒ match u2 with [ uch_h ⇒ true | _ ⇒ false ]
381 | uch_i ⇒ match u2 with [ uch_i ⇒ true | _ ⇒ false ]
382 | uch_j ⇒ match u2 with [ uch_j ⇒ true | _ ⇒ false ]
383 | uch_k ⇒ match u2 with [ uch_k ⇒ true | _ ⇒ false ]
384 | uch_l ⇒ match u2 with [ uch_l ⇒ true | _ ⇒ false ]
385 | uch_m ⇒ match u2 with [ uch_m ⇒ true | _ ⇒ false ]
386 | uch_n ⇒ match u2 with [ uch_n ⇒ true | _ ⇒ false ]
387 | uch_o ⇒ match u2 with [ uch_o ⇒ true | _ ⇒ false ]
388 | uch_p ⇒ match u2 with [ uch_p ⇒ true | _ ⇒ false ]
389 | uch_q ⇒ match u2 with [ uch_q ⇒ true | _ ⇒ false ]
390 | uch_r ⇒ match u2 with [ uch_r ⇒ true | _ ⇒ false ]
391 | uch_s ⇒ match u2 with [ uch_s ⇒ true | _ ⇒ false ]
392 | uch_t ⇒ match u2 with [ uch_t ⇒ true | _ ⇒ false ]
393 | uch_u ⇒ match u2 with [ uch_u ⇒ true | _ ⇒ false ]
394 | uch_v ⇒ match u2 with [ uch_v ⇒ true | _ ⇒ false ]
395 | uch_w ⇒ match u2 with [ uch_w ⇒ true | _ ⇒ false ]
396 | uch_x ⇒ match u2 with [ uch_x ⇒ true | _ ⇒ false ]
397 | uch_y ⇒ match u2 with [ uch_y ⇒ true | _ ⇒ false ]
398 | uch_z ⇒ match u2 with [ uch_z ⇒ true | _ ⇒ false ]
400 | ADC ⇒ match u2 with [ ADC ⇒ true | _ ⇒ false ]
401 | ADD ⇒ match u2 with [ ADD ⇒ true | _ ⇒ false ]
402 | AIS ⇒ match u2 with [ AIS ⇒ true | _ ⇒ false ]
403 | AIX ⇒ match u2 with [ AIX ⇒ true | _ ⇒ false ]
404 | AND ⇒ match u2 with [ AND ⇒ true | _ ⇒ false ]
405 | ASL ⇒ match u2 with [ ASL ⇒ true | _ ⇒ false ]
406 | ASR ⇒ match u2 with [ ASR ⇒ true | _ ⇒ false ]
407 | BCC ⇒ match u2 with [ BCC ⇒ true | _ ⇒ false ]
408 | BCLRn ⇒ match u2 with [ BCLRn ⇒ true | _ ⇒ false ]
409 | BCS ⇒ match u2 with [ BCS ⇒ true | _ ⇒ false ]
410 | BEQ ⇒ match u2 with [ BEQ ⇒ true | _ ⇒ false ]
411 | BGE ⇒ match u2 with [ BGE ⇒ true | _ ⇒ false ]
412 | BGND ⇒ match u2 with [ BGND ⇒ true | _ ⇒ false ]
413 | BGT ⇒ match u2 with [ BGT ⇒ true | _ ⇒ false ]
414 | BHCC ⇒ match u2 with [ BHCC ⇒ true | _ ⇒ false ]
415 | BHCS ⇒ match u2 with [ BHCS ⇒ true | _ ⇒ false ]
416 | BHI ⇒ match u2 with [ BHI ⇒ true | _ ⇒ false ]
417 | BIH ⇒ match u2 with [ BIH ⇒ true | _ ⇒ false ]
418 | BIL ⇒ match u2 with [ BIL ⇒ true | _ ⇒ false ]
419 | BIT ⇒ match u2 with [ BIT ⇒ true | _ ⇒ false ]
420 | BLE ⇒ match u2 with [ BLE ⇒ true | _ ⇒ false ]
421 | BLS ⇒ match u2 with [ BLS ⇒ true | _ ⇒ false ]
422 | BLT ⇒ match u2 with [ BLT ⇒ true | _ ⇒ false ]
423 | BMC ⇒ match u2 with [ BMC ⇒ true | _ ⇒ false ]
424 | BMI ⇒ match u2 with [ BMI ⇒ true | _ ⇒ false ]
425 | BMS ⇒ match u2 with [ BMS ⇒ true | _ ⇒ false ]
426 | BNE ⇒ match u2 with [ BNE ⇒ true | _ ⇒ false ]
427 | BPL ⇒ match u2 with [ BPL ⇒ true | _ ⇒ false ]
428 | BRA ⇒ match u2 with [ BRA ⇒ true | _ ⇒ false ]
429 | BRCLRn ⇒ match u2 with [ BRCLRn ⇒ true | _ ⇒ false ]
430 | BRN ⇒ match u2 with [ BRN ⇒ true | _ ⇒ false ]
431 | BRSETn ⇒ match u2 with [ BRSETn ⇒ true | _ ⇒ false ]
432 | BSETn ⇒ match u2 with [ BSETn ⇒ true | _ ⇒ false ]
433 | BSR ⇒ match u2 with [ BSR ⇒ true | _ ⇒ false ]
434 | CBEQA ⇒ match u2 with [ CBEQA ⇒ true | _ ⇒ false ]
435 | CBEQX ⇒ match u2 with [ CBEQX ⇒ true | _ ⇒ false ]
436 | CLC ⇒ match u2 with [ CLC ⇒ true | _ ⇒ false ]
437 | CLI ⇒ match u2 with [ CLI ⇒ true | _ ⇒ false ]
438 | CLR ⇒ match u2 with [ CLR ⇒ true | _ ⇒ false ]
439 | CMP ⇒ match u2 with [ CMP ⇒ true | _ ⇒ false ]
440 | COM ⇒ match u2 with [ COM ⇒ true | _ ⇒ false ]
441 | CPHX ⇒ match u2 with [ CPHX ⇒ true | _ ⇒ false ]
442 | CPX ⇒ match u2 with [ CPX ⇒ true | _ ⇒ false ]
443 | DAA ⇒ match u2 with [ DAA ⇒ true | _ ⇒ false ]
444 | DBNZ ⇒ match u2 with [ DBNZ ⇒ true | _ ⇒ false ]
445 | DEC ⇒ match u2 with [ DEC ⇒ true | _ ⇒ false ]
446 | DIV ⇒ match u2 with [ DIV ⇒ true | _ ⇒ false ]
447 | EOR ⇒ match u2 with [ EOR ⇒ true | _ ⇒ false ]
448 | INC ⇒ match u2 with [ INC ⇒ true | _ ⇒ false ]
449 | JMP ⇒ match u2 with [ JMP ⇒ true | _ ⇒ false ]
450 | JSR ⇒ match u2 with [ JSR ⇒ true | _ ⇒ false ]
451 | LDA ⇒ match u2 with [ LDA ⇒ true | _ ⇒ false ]
452 | LDHX ⇒ match u2 with [ LDHX ⇒ true | _ ⇒ false ]
453 | LDX ⇒ match u2 with [ LDX ⇒ true | _ ⇒ false ]
454 | LSR ⇒ match u2 with [ LSR ⇒ true | _ ⇒ false ]
455 | MOV ⇒ match u2 with [ MOV ⇒ true | _ ⇒ false ]
456 | MUL ⇒ match u2 with [ MUL ⇒ true | _ ⇒ false ]
457 | NEG ⇒ match u2 with [ NEG ⇒ true | _ ⇒ false ]
458 | NOP ⇒ match u2 with [ NOP ⇒ true | _ ⇒ false ]
459 | NSA ⇒ match u2 with [ NSA ⇒ true | _ ⇒ false ]
460 | ORA ⇒ match u2 with [ ORA ⇒ true | _ ⇒ false ]
461 | PSHA ⇒ match u2 with [ PSHA ⇒ true | _ ⇒ false ]
462 | PSHH ⇒ match u2 with [ PSHH ⇒ true | _ ⇒ false ]
463 | PSHX ⇒ match u2 with [ PSHX ⇒ true | _ ⇒ false ]
464 | PULA ⇒ match u2 with [ PULA ⇒ true | _ ⇒ false ]
465 | PULH ⇒ match u2 with [ PULH ⇒ true | _ ⇒ false ]
466 | PULX ⇒ match u2 with [ PULX ⇒ true | _ ⇒ false ]
467 | ROL ⇒ match u2 with [ ROL ⇒ true | _ ⇒ false ]
468 | ROR ⇒ match u2 with [ ROR ⇒ true | _ ⇒ false ]
469 | RSP ⇒ match u2 with [ RSP ⇒ true | _ ⇒ false ]
470 | RTI ⇒ match u2 with [ RTI ⇒ true | _ ⇒ false ]
471 | RTS ⇒ match u2 with [ RTS ⇒ true | _ ⇒ false ]
472 | SBC ⇒ match u2 with [ SBC ⇒ true | _ ⇒ false ]
473 | SEC ⇒ match u2 with [ SEC ⇒ true | _ ⇒ false ]
474 | SEI ⇒ match u2 with [ SEI ⇒ true | _ ⇒ false ]
475 | SHA ⇒ match u2 with [ SHA ⇒ true | _ ⇒ false ]
476 | SLA ⇒ match u2 with [ SLA ⇒ true | _ ⇒ false ]
477 | STA ⇒ match u2 with [ STA ⇒ true | _ ⇒ false ]
478 | STHX ⇒ match u2 with [ STHX ⇒ true | _ ⇒ false ]
479 | STOP ⇒ match u2 with [ STOP ⇒ true | _ ⇒ false ]
480 | STX ⇒ match u2 with [ STX ⇒ true | _ ⇒ false ]
481 | SUB ⇒ match u2 with [ SUB ⇒ true | _ ⇒ false ]
482 | SWI ⇒ match u2 with [ SWI ⇒ true | _ ⇒ false ]
483 | TAP ⇒ match u2 with [ TAP ⇒ true | _ ⇒ false ]
484 | TAX ⇒ match u2 with [ TAX ⇒ true | _ ⇒ false ]
485 | TPA ⇒ match u2 with [ TPA ⇒ true | _ ⇒ false ]
486 | TST ⇒ match u2 with [ TST ⇒ true | _ ⇒ false ]
487 | TSX ⇒ match u2 with [ TSX ⇒ true | _ ⇒ false ]
488 | TXA ⇒ match u2 with [ TXA ⇒ true | _ ⇒ false ]
489 | TXS ⇒ match u2 with [ TXS ⇒ true | _ ⇒ false ]
490 | WAIT ⇒ match u2 with [ WAIT ⇒ true | _ ⇒ false ]
494 ndefinition UN_destruct : ∀x,y.∀P:Prop.x = y → match eq_UN x y with [ true ⇒ P → P | false ⇒ P ].
502 nlemma eq_to_eqUN : ∀e1,e2.e1 = e2 → eq_UN e1 e2 = true.
510 nlemma pippo : ∀A,B:Prop.(A → B) → ((¬B) → (¬A)).
511 #A; #B; #H; nnormalize;
516 nlemma pluto1 : ∀x.x = false → x ≠ true.
518 ##[ ##1: #H; napply (bool_destruct … H)
519 ##| ##2: #H; nnormalize; #H1; napply (bool_destruct … H1)
523 nlemma pluto2 : ∀x.x = true → x ≠ false.
525 ##[ ##1: #H; nnormalize; #H1; napply (bool_destruct … H1)
526 ##| ##2: #H; napply (bool_destruct … H)
530 nlemma pluto3 : ∀x.x ≠ false → x = true.
532 ##[ ##1: #H; napply refl_eq
533 ##| ##2: nnormalize; #H; nelim (H (refl_eq …))
537 nlemma pluto4 : ∀x.x ≠ true → x = false.
539 ##[ ##1: nnormalize; #H; nelim (H (refl_eq …))
540 ##| ##2: #H; napply refl_eq
544 nlemma neqUN_to_neq : ∀e1,e2.eq_UN e1 e2 = false → e1 ≠ e2.
546 napply (pippo (e1 = e2) (eq_UN e1 e2 = true) …);
547 ##[ ##1: napply (eq_to_eqUN e1 e2)
548 ##| ##2: napply (pluto1 … H)
552 naxiom eqUN_to_eq : ∀e1,e2.eq_UN e1 e2 = true → e1 = e2.
554 nlemma neq_to_neqUN : ∀e1,e2.e1 ≠ e2 → eq_UN e1 e2 = false.
556 napply (pluto4 (eq_UN e1 e2));
557 napply (pippo (eq_UN e1 e2 = true) (e1 = e2) ? H);
558 napply (eqUN_to_eq e1 e2).
561 nlemma decidable_UN : ∀x,y:UN.decidable (x = y).
563 napply (or2_elim (eq_UN x y = true) (eq_UN x y = false) ?);
564 ##[ ##1: ncases (eq_UN x y);
565 ##[ ##1: napply (or2_intro1 (true = true) (true = false) (refl_eq …))
566 ##| ##2: napply (or2_intro2 (false = true) (false = false) (refl_eq …))
568 ##| ##2: #H; napply (or2_intro1 (x = y) (x ≠ y) (eqUN_to_eq … H))
569 ##| ##3: #H; napply (or2_intro2 (x = y) (x ≠ y) (neqUN_to_neq … H))
573 nrewrite > (eq_to_eqUN e1 e2 ?);
575 nlemma eqUN_to_eq : ∀e1,e2.eq_UN e1 e2 = true → e1 = e2.
579 nlemma pippo : ∀P.(¬¬¬P) → (¬P).
580 #P; nnormalize; #H; #H1;
585 nlemma pippo2 : ∀P.(¬¬P) → P.
587 napply (or2_elim (¬P) (¬¬¬¬P) ?);
588 ##[ ##1: napply (or2_intro2 ?? (prop_to_nnprop ? H))
589 ##| ##2: #H1; nelim (H H1)
590 ##| ##3: #H1; napply False_ind;
591 napply (H (pippo …));
600 ##[ ##2: #H1;napply (prop_to_nnprop ? H);
601 ##| ##1: nnormalize; #H1;
605 napply (or2_elim (¬¬P) (¬¬¬P) ?);
606 ##[ ##1: napply (or2_intro1 ?? H);
608 napply (absurd (¬¬¬P) P ??);
609 ##[ ##2: napply (prop_to_nnprop ? H);
616 napply (absurd ? False H ?);
622 napply (absurd ? False (prop_to_nnprop (¬P) ?));
623 ##[ ##1: nnormalize; #H2; napply (H2 H)
630 nlemma eqUN_to_eq : ∀e1,e2.eq_UN e1 e2 = true → e1 = e2.
632 napply (or2_elim (eq_UN e1 e2 = false) (e1 ≠ e2) ?);
636 nchange with (match e2 with [ ? ⇒ true | _ ⇒ false ]);
639 napply (or2_elim (e1 = e2) (e1 ≠ e2) …);
642 ##[ ##1: ncases (eq_UN e1 e2);
643 ##[ ##1: napply (or2_intro1 (true = true) (true = false) (refl_eq …))
644 ##| ##2: napply (or2_intro2 (false = true) (false = false) (refl_eq …))
656 ndefinition decidable_UN1 ≝ λx.∀y:UN.decidable (x = y).
660 ##[ ##1: napply (or2_intro1 (? = ?) (? ≠ ?) …); napply refl_eq
661 ##| ##*: napply (or2_intro2 (? = ?) (? ≠ ?) …); #H; napply (UN_destruct … H)
665 naxiom decidable_UN : ∀x,y:UN.decidable (x = y).
667 nlemma neq_to_neqUN : ∀e1,e2.e1 ≠ e2 → eq_UN e1 e2 = false.
670 nlemma eqUN_to_eq : ∀e1,e2.eq_UN e1 e2 = true → e1 = e2.
671 #e1; #e2; #H; napply (or2_elim ??? (decidable_UN e1 e2));
674 nlemma pippo : ∀e1,e2:UN.decidable (e1 = e2).
675 #e1; #e2; nnormalize;
677 napply (or2_intro1 (? = ?) (? ≠ ?) …);
678 nchange with (match e2 with [ ? ⇒ refl_eq UN ? | _ ⇒ ? ]);
679 napply (destruct_UN ? e2 (? = e2) ?);
681 nlemma pippo : ∀e1,e2.eq_UN e1 e2 = true → e1 = e2.
685 (* costruttore di un sottouniverso:
686 S_EL cioe' uno qualsiasi degli elementi del sottouniverso
687 S_KO cioe' il caso impossibile
689 ninductive S_UN (l:list UN) : Type ≝
690 S_EL : Πx:UN.((member_list UN x eq_UN l) = true) →
691 (∀y.x = y → (eq_UN x y = true)) →
692 (∀y.(eq_UN x y = true) → x = y) →
693 (∀y.decidable (x = y)) →
694 (∀y.x ≠ y → (eq_UN x y = false)) →
695 (∀y.(eq_UN x y = false) → x ≠ y) →
697 | S_KO : False → S_UN l.
699 ndefinition SUN_create : Πl.Πe.(member_list UN e eq_UN l = true) → S_UN l.
700 #l; #e; #dim; napply (S_EL l e dim …);
701 ##[ ##1: #y; #H; nrewrite > H; nelim y; nnormalize; napply refl_eq
704 (* sottoinsieme degli esadecimali *)
705 ndefinition EX_UN ≝ [ ux0; ux1; ux2; ux3; ux4; ux5; ux6; ux7; ux8; ux9; uxA; uxB; uxC; uxD; uxE; uxF ].
707 (* getter del testimone di esistenza *)
708 ndefinition getelem : ∀l.∀e:S_UN l.UN.
710 ##[ ##1: #u; #H; napply u
715 (* getter della dimostrazione di appartenenza *)
716 ndefinition getdim : ∀l.∀e:S_UN l.member_list UN ? eq_UN l = true.
718 ##[ ##1: #u; #H; napply u
721 ##| ##1: #l; #s; nelim s;
722 ##[ ##1: #u; #m; napply m
728 (* costruttore universale di una funzione ad un solo argomento: esadecimali → esadecimali *)
731 ∀f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,f14,f15,f16:S_UN EX_UN.
733 #input; #f1; #f2; #f3; #f4; #f5; #f6; #f7; #f8; #f9; #f10; #f11; #f12; #f13; #f14; #f15; #f16;
736 ##| ##1: #u; #H; nelim u in H:(%); #H;
737 ##[ ##13: napply f1 ##| ##14: napply f2 ##| ##15: napply f3 ##| ##16: napply f4
738 ##| ##17: napply f5 ##| ##18: napply f6 ##| ##19: napply f7 ##| ##20: napply f8
739 ##| ##21: napply f9 ##| ##22: napply f10 ##| ##23: napply f11 ##| ##24: napply f12
740 ##| ##25: napply f13 ##| ##26: napply f14 ##| ##27: napply f15 ##| ##28: napply f16
741 ##| ##*: nnormalize in H:(%); napply (S_KO EX_UN (bool_destruct false true False H))
746 (* esempio: successore esadecimale *)
747 ndefinition succ_EX_UN ≝
748 λe:S_UN EX_UN.f1_EX_UN
749 (S_EL EX_UN ux1 (refl_eq …)) (S_EL EX_UN ux2 (refl_eq …))
750 (S_EL EX_UN ux3 (refl_eq …)) (S_EL EX_UN ux4 (refl_eq …))
751 (S_EL EX_UN ux5 (refl_eq …)) (S_EL EX_UN ux6 (refl_eq …))
752 (S_EL EX_UN ux7 (refl_eq …)) (S_EL EX_UN ux8 (refl_eq …))
753 (S_EL EX_UN ux9 (refl_eq …)) (S_EL EX_UN uxA (refl_eq …))
754 (S_EL EX_UN uxB (refl_eq …)) (S_EL EX_UN uxC (refl_eq …))
755 (S_EL EX_UN uxD (refl_eq …)) (S_EL EX_UN uxE (refl_eq …))
756 (S_EL EX_UN uxF (refl_eq …)) (S_EL EX_UN ux0 (refl_eq …)).
759 nlemma same_UN_1 : ∀l.∀e1,e2.∀dim1,dim2.S_EL l e1 dim1 = S_EL l e2 dim2 → e1 = e2.
760 #l; #e1; #e2; #dim1; #dim2; #H;
761 nchange with (match S_EL l e2 dim2 with [ S_EL a _ ⇒ e1 = a | S_KO _ ⇒ False ]);
769 ndefinition destruct_SUN
770 : ∀l.∀e1,e2:S_UN l.∀P:Prop.
771 e1 = e2 → match eq_UN (getelem ? e1) (getelem ? e2) with [ true ⇒ P → P | false ⇒ P ].
774 ##| ##1: #u1; #dim1; #e2; ncases e2;
776 ##| ##1: #u2; #dim2; #P; #H;
777 nchange with (match eq_UN u1 u2 with [ true ⇒ P → P | false ⇒ P ]);
778 napply (destruct_UN u1 u2 P (same_UN_1 l … H))
786 : ∀l.∀e1,e2:S_UN l.(getelem ? e1) = (getelem ? e2) → eq_UN (getelem ? e1) (getelem ? e2) = true.
789 ##| ##1: #u1; #dim1; #e2; ncases e2;
790 ##[ ##2: #H; nelim H;
791 ##| ##1: #u2; #dim2; nchange with ((u1 = u2) → (eq_UN u1 u2 = true));
792 napply (eq_to_eqUN u1 u2);
797 nlet rec scan (T:Type) (e:T) (f:T → T → bool) (l:list T) (n:nat) on l ≝
800 | cons h t ⇒ match f e h with
802 | false ⇒ scan T e f t (S n)
806 nlemma pippo : ∀l.∀x,y:S_UN l.x = y → scan ? (getelem ? x) eq_UN l O = scan ? (getelem ? y) eq_UN l O.
808 ##[ ##1: #x; #y; #H; nnormalize; napply refl_eq
809 ##| ##2: #hh; #tt; #H; #x; nelim x;
811 ##| ##1: #u1; #dim1; #y; nelim y;
813 ##| ##1: #u2; #dim2; #H1;
814 nchange with ((scan ? u1 ???) = (scan ? u2 ???));
815 nrewrite > (same_UN_1 (hh::tt) … H1);
817 nletin K ≝ (same_UN_1 (hh::tt) … H1);
818 nchange in K:(%) with (u1 = u2);
820 nrewrite > (same_UN_1 (hh::tt) … H1) in dim1:(%) dim2:(%) ⊢ %;
821 nchange with (match eq_UN
823 nchange with (scan ? u1 eq_UN ? O = scan ? u2 eq_UN ? O);
827 ##| ##1: #u1; #dim1; #y; nelim y;
829 ##| ##1: #u2; #dim2; #H; nchange with (scan ? u1 eq_UN l O = scan ? u2 eq_UN l O);
830 nrewrite > (same_UN_1 l … H);
831 nelim l in x:(%) dim1:(%) y:(%) dim2:(%) H:(%) ⊢ %;
832 ##[ ##1: #x; #dim1; #y; #dim2; #H; nnormalize; napply refl_eq
833 ##| ##2: #uu1; #ll; #H; #y;
836 nlemma decidable_UN : ∀x,y:UN.decidable (x = y).
841 napply (destruct_UN ? y (Or2 ??) ?);
844 : ∀l.∀e1,e2:S_UN l.(getelem ? e1) ≠ (getelem ? e2) → eq_UN (getelem ? e1) (getelem ? e2) = false.
847 ##| ##1: #u1; #dim1; #e2; ncases e2;
848 ##[ ##2: #H; nelim H;
849 ##| ##1: #u2; #dim2; nchange with ((u1 ≠ u2) → (eq_UN u1 u2 = false));
851 nelim u2; nnormalize; napply refl_eq
856 nelim u1 in dim1:(%) H:(%) ⊢ %; #dim1; #H;
857 ##[ ##1: nelim u2 in dim2:(%) H:(%) ⊢ %; #dim2; #H;
858 napply (destruct_UN l (S_EL l uq0 dim1) ?? H);
860 ##[ ##1: nelim u2; ##[ ##1:
863 ndefinition decidable_UN : ∀l.∀e1,e2:S_UN l.decidable (e1 = e2).
866 ##| ##1: #u1; #dim1; #e2; ncases e2;
868 ##| ##1: #u2; #dim2; nnormalize;
869 napply (or2_intro2 (? = ?) (? ≠ ?) ?);
872 nchange with (match S_EL l u1 dim1
873 return λx.eq_UN x u2 → Prop
875 [ S_EL x _ ⇒ λp:(False
877 ] (refl_eq ? (eq_UN u1 u2);
878 nletin K ≝ (same_UN_1 l … H);
879 nelim u1 in dim1:(%) H:(%) K:(%);
881 napply (destruct_UN l … H);