src/ZF/ex/ListN.ML
changeset 1732 38776e927da8
parent 1461 6bcb44e4d6e5
child 2469 b50b8c0eec01
equal deleted inserted replaced
1731:2ad693c6cb13 1732:38776e927da8
     9 Research Report 92-49, LIP, ENS Lyon.  Dec 1992.
     9 Research Report 92-49, LIP, ENS Lyon.  Dec 1992.
    10 *)
    10 *)
    11 
    11 
    12 open ListN;
    12 open ListN;
    13 
    13 
    14 val listn_induct = standard 
       
    15     (listn.mutual_induct RS spec RS spec RSN (2,rev_mp));
       
    16 
       
    17 goal ListN.thy "!!l. l:list(A) ==> <length(l),l> : listn(A)";
    14 goal ListN.thy "!!l. l:list(A) ==> <length(l),l> : listn(A)";
    18 by (etac list.induct 1);
    15 by (etac list.induct 1);
    19 by (ALLGOALS (asm_simp_tac list_ss));
    16 by (ALLGOALS (asm_simp_tac list_ss));
    20 by (REPEAT (ares_tac listn.intrs 1));
    17 by (REPEAT (ares_tac listn.intrs 1));
    21 qed "list_into_listn";
    18 qed "list_into_listn";
    22 
    19 
    23 goal ListN.thy "<n,l> : listn(A) <-> l:list(A) & length(l)=n";
    20 goal ListN.thy "<n,l> : listn(A) <-> l:list(A) & length(l)=n";
    24 by (rtac iffI 1);
    21 by (rtac iffI 1);
    25 by (etac listn_induct 1);
    22 by (etac listn.induct 1);
    26 by (safe_tac (ZF_cs addSIs (list_typechecks @
    23 by (safe_tac (ZF_cs addSIs (list_typechecks @
    27                             [length_Nil, length_Cons, list_into_listn])));
    24                             [length_Nil, length_Cons, list_into_listn])));
    28 qed "listn_iff";
    25 qed "listn_iff";
    29 
    26 
    30 goal ListN.thy "listn(A)``{n} = {l:list(A). length(l)=n}";
    27 goal ListN.thy "listn(A)``{n} = {l:list(A). length(l)=n}";
    39 qed "listn_mono";
    36 qed "listn_mono";
    40 
    37 
    41 goal ListN.thy
    38 goal ListN.thy
    42     "!!n l. [| <n,l> : listn(A);  <n',l'> : listn(A) |] ==> \
    39     "!!n l. [| <n,l> : listn(A);  <n',l'> : listn(A) |] ==> \
    43 \           <n#+n', l@l'> : listn(A)";
    40 \           <n#+n', l@l'> : listn(A)";
    44 by (etac listn_induct 1);
    41 by (etac listn.induct 1);
    45 by (ALLGOALS (asm_simp_tac (list_ss addsimps listn.intrs)));
    42 by (ALLGOALS (asm_simp_tac (list_ss addsimps listn.intrs)));
    46 qed "listn_append";
    43 qed "listn_append";
    47 
    44 
    48 val Nil_listn_case = listn.mk_cases list.con_defs "<i,Nil> : listn(A)"
    45 val Nil_listn_case = listn.mk_cases list.con_defs "<i,Nil> : listn(A)"
    49 and Cons_listn_case = listn.mk_cases list.con_defs "<i,Cons(x,l)> : listn(A)";
    46 and Cons_listn_case = listn.mk_cases list.con_defs "<i,Cons(x,l)> : listn(A)";