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 set "baseuri" "cic:/matita/tests/coercions/".
17 include "nat/compare.ma".
18 include "nat/times.ma".
20 inductive pos: Set \def
24 inductive int: Set \def
25 | positive: nat \to int
26 | negative : nat \to int.
28 inductive empty : Set \def .
30 let rec pos2nat x \def
32 [ one \Rightarrow (S O)
33 | (next z) \Rightarrow S (pos2nat z)].
35 definition nat2int \def \lambda x. positive x.
37 coercion cic:/matita/tests/coercions/pos2nat.con.
39 coercion cic:/matita/tests/coercions/nat2int.con.
41 definition fst \def \lambda x,y:int.x.
43 theorem a: fst O one = fst (positive O) (next one).
48 \forall f:int \to int. pos \to int
50 \lambda f:int \to int. \lambda x : pos .f (nat2int x).
53 \forall f:int \to int. pos \to int
55 \lambda f:int \to int. \lambda x : pos .f (pos2nat x).
58 \forall f:int \to int. pos \to int
60 \lambda f:int \to int. \lambda x : pos .f (nat2int (pos2nat x)).
62 (* This used to test eq_f as a coercion. However, posing both eq_f and sym_eq
63 as coercions made the qed time of some TPTP problems reach infty.
64 Thus eq_f is no longer a coercion (nor is sym_eq).
65 theorem coercion_svelta : \forall T,S:Type.\forall f:T \to S.\forall x,y:T.x=y \to f y = f x.
67 apply ((\lambda h:f y = f x.h) H).
71 variant pos2nat' : ? \def pos2nat.
73 inductive initial: Set \def iii : initial.
75 definition i2pos: ? \def \lambda x:initial.one.
77 coercion cic:/matita/tests/coercions/i2pos.con.
79 coercion cic:/matita/tests/coercions/pos2nat'.con.
81 inductive listn (A:Type) : nat \to Type \def
83 | Next : \forall n.\forall l:listn A n.\forall a:A.listn A (S n).
85 definition if : \forall A:Type.\forall b:bool.\forall a,c:A.A \def
89 | false \Rightarrow c].
91 let rec ith (A:Type) (n,m:nat) (dummy:A) (l:listn A n) on l \def
93 [ Nil \Rightarrow dummy
94 | (Next w l x) \Rightarrow if A (eqb w m) x (ith A w m dummy l)].
96 definition listn2function:
97 \forall A:Type.\forall dummy:A.\forall n.listn A n \to nat \to A
99 \lambda A,dummy,n,l,m.ith A n m dummy l.
101 definition natlist2map: ? \def listn2function nat O.
103 coercion cic:/matita/tests/coercions/natlist2map.con 1.
104 definition map: \forall n:nat.\forall l:listn nat n. nat \to nat \def
105 \lambda n:nat.\lambda l:listn nat n.\lambda m:nat.l m.
107 definition church: nat \to nat \to nat \def times.
109 coercion cic:/matita/tests/coercions/church.con 1.
111 definition mapmult: \forall n:nat.\forall l:listn nat n. nat \to nat \to nat \def
112 \lambda n:nat.\lambda l:listn nat n.\lambda m,o:nat.