(* ========================================================================== *)
(* ========================================================================== *)
(* FLYSPECK - BOOK FORMALIZATION *)
(* *)
(* Chapter: Jordan *)
(* Copied from HOL Light jordan directory *)
(* Author: Thomas C. Hales *)
(* Date: 2010-07-08 *)
(* ========================================================================== *)
(* needs tactics_ext.ml *)
module Num_ext_nabs = struct
open Tactics_jordan;;
Parse_ext_override_interface.unambiguous_interface();;
let INT_REP2 = prove( `!a. ?n. ((a = (&: n)) \/ (a = (--: (&: n))))`,
(GEN_TAC)
THEN ((let tt =(REWRITE_RULE[
is_int] (SPEC (`a:int`)
INT_IS_INT)) in
(CHOOSE_TAC tt)))
THEN ((POP_ASSUM DISJ_CASES_TAC))
THENL
[ ((EXISTS_TAC (`n:num`)))
THEN ((ASM_REWRITE_TAC[GSYM
INT_OF_NUM_DEST]));
((EXISTS_TAC (`n:num`)))
(* THEN ((RULE_EL 0 (REWRITE_RULE[GSYM REAL_NEG_EQ;GSYM int_neg_th]))) *)
THEN (H_REWRITE_RULE[THM (GSYM
REAL_NEG_EQ);THM (GSYM
int_neg_th)] (HYP_INT 0))
THEN ((ASM_REWRITE_TAC[GSYM
INT_NEG_EQ;GSYM
INT_OF_NUM_DEST]))]);;
(* ------------------------------------------------------------------ *)
(* nabs : int -> num gives the natural number abs. value of an int *)
(* ------------------------------------------------------------------ *)
let NABS_POS = prove(`!u. (
nabs (
int_of_num u)) = u`,
GEN_TAC
THEN (REWRITE_TAC [
nabs])
THEN (MATCH_MP_TAC
SELECT_UNIQUE)
THEN (GEN_TAC THEN BETA_TAC)
THEN (EQ_TAC)
THENL [(TAUT_TAC (` ((A==>C)/\ (B==>C)) ==> (A\/B ==>C) `));
MESON_TAC[]]
THEN CONJ_TAC THENL
(let branch2 = (REWRITE_TAC[
int_eq;
int_neg_th;
INT_NUM_REAL])
THEN (REWRITE_TAC[prove (`! u y.(((real_of_num u) = --(real_of_num y))=
((real_of_num u) +(real_of_num y) = (&0)))`,REAL_ARITH_TAC)])
THEN (REWRITE_TAC[REAL_OF_NUM_ADD;REAL_OF_NUM_EQ])
THEN (MESON_TAC[
ADD_EQ_0]) in
[(REWRITE_TAC[
int_eq;
INT_NUM_REAL]);branch2])
THEN (REWRITE_TAC[
INT_NUM_REAL])
THEN (MESON_TAC[REAL_OF_NUM_EQ]));;
end;;