src/CCL/ex/Nat.ML
changeset 757 2ca12511676d
parent 8 c3d2c6dcf3f0
child 1459 d12da312eff4
equal deleted inserted replaced
756:e0e5c1581e4c 757:2ca12511676d
    25 (*** Lemma for napply ***)
    25 (*** Lemma for napply ***)
    26 
    26 
    27 val [prem] = goal Nat.thy "n:Nat ==> f^n`f(a) = f^succ(n)`a";
    27 val [prem] = goal Nat.thy "n:Nat ==> f^n`f(a) = f^succ(n)`a";
    28 br (prem RS Nat_ind) 1;
    28 br (prem RS Nat_ind) 1;
    29 by (ALLGOALS (asm_simp_tac nat_ss));
    29 by (ALLGOALS (asm_simp_tac nat_ss));
    30 val napply_f = result();
    30 qed "napply_f";
    31 
    31 
    32 (****)
    32 (****)
    33 
    33 
    34 val prems = goalw Nat.thy [add_def] "[| a:Nat;  b:Nat |] ==> a #+ b : Nat";
    34 val prems = goalw Nat.thy [add_def] "[| a:Nat;  b:Nat |] ==> a #+ b : Nat";
    35 by (typechk_tac prems 1);
    35 by (typechk_tac prems 1);
    36 val addT = result();
    36 qed "addT";
    37 
    37 
    38 val prems = goalw Nat.thy [mult_def] "[| a:Nat;  b:Nat |] ==> a #* b : Nat";
    38 val prems = goalw Nat.thy [mult_def] "[| a:Nat;  b:Nat |] ==> a #* b : Nat";
    39 by (typechk_tac (addT::prems) 1);
    39 by (typechk_tac (addT::prems) 1);
    40 val multT = result();
    40 qed "multT";
    41 
    41 
    42 (* Defined to return zero if a<b *)
    42 (* Defined to return zero if a<b *)
    43 val prems = goalw Nat.thy [sub_def] "[| a:Nat;  b:Nat |] ==> a #- b : Nat";
    43 val prems = goalw Nat.thy [sub_def] "[| a:Nat;  b:Nat |] ==> a #- b : Nat";
    44 by (typechk_tac (prems) 1);
    44 by (typechk_tac (prems) 1);
    45 by clean_ccs_tac;
    45 by clean_ccs_tac;
    46 be (NatPRI RS wfstI RS (NatPR_wf RS wmap_wf RS wfI)) 1;
    46 be (NatPRI RS wfstI RS (NatPR_wf RS wmap_wf RS wfI)) 1;
    47 val subT = result();
    47 qed "subT";
    48 
    48 
    49 val prems = goalw Nat.thy [le_def] "[| a:Nat;  b:Nat |] ==> a #<= b : Bool";
    49 val prems = goalw Nat.thy [le_def] "[| a:Nat;  b:Nat |] ==> a #<= b : Bool";
    50 by (typechk_tac (prems) 1);
    50 by (typechk_tac (prems) 1);
    51 by clean_ccs_tac;
    51 by clean_ccs_tac;
    52 be (NatPRI RS wfstI RS (NatPR_wf RS wmap_wf RS wfI)) 1;
    52 be (NatPRI RS wfstI RS (NatPR_wf RS wmap_wf RS wfI)) 1;
    53 val leT = result();
    53 qed "leT";
    54 
    54 
    55 val prems = goalw Nat.thy [not_def,lt_def] "[| a:Nat;  b:Nat |] ==> a #< b : Bool";
    55 val prems = goalw Nat.thy [not_def,lt_def] "[| a:Nat;  b:Nat |] ==> a #< b : Bool";
    56 by (typechk_tac (prems@[leT]) 1);
    56 by (typechk_tac (prems@[leT]) 1);
    57 val ltT = result();
    57 qed "ltT";
    58 
    58 
    59 (* Correctness conditions for subtractive division **)
    59 (* Correctness conditions for subtractive division **)
    60 
    60 
    61 val prems = goalw Nat.thy [div_def] 
    61 val prems = goalw Nat.thy [div_def] 
    62     "[| a:Nat;  b:{x:Nat.~x=zero} |] ==> a ## b : {x:Nat. DIV(a,b,x)}";
    62     "[| a:Nat;  b:{x:Nat.~x=zero} |] ==> a ## b : {x:Nat. DIV(a,b,x)}";