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 theorem coercion_svelta : \forall T,S:Type.\forall f:T \to S.\forall x,y:T.x=y \to f y = f x.
64 apply ((\lambda h:f y = f x.h) H).
67 variant pos2nat' : ? \def pos2nat.
69 inductive initial: Set \def iii : initial.
71 definition i2pos: ? \def \lambda x:initial.one.
73 coercion cic:/matita/tests/coercions/i2pos.con.
75 coercion cic:/matita/tests/coercions/pos2nat'.con.
77 inductive listn (A:Type) : nat \to Type \def
79 | Next : \forall n.\forall l:listn A n.\forall a:A.listn A (S n).
81 definition if : \forall A:Type.\forall b:bool.\forall a,c:A.A \def
85 | false \Rightarrow c].
87 let rec ith (A:Type) (n,m:nat) (dummy:A) (l:listn A n) on l \def
89 [ Nil \Rightarrow dummy
90 | (Next w l x) \Rightarrow if A (eqb w m) x (ith A w m dummy l)].
92 definition listn2function:
93 \forall A:Type.\forall dummy:A.\forall n.listn A n \to nat \to A
95 \lambda A,dummy,n,l,m.ith A n m dummy l.
97 definition natlist2map: ? \def listn2function nat O.
99 coercion cic:/matita/tests/coercions/natlist2map.con 1.
100 definition map: \forall n:nat.\forall l:listn nat n. nat \to nat \def
101 \lambda n:nat.\lambda l:listn nat n.\lambda m:nat.l m.
103 definition church: nat \to nat \to nat \def times.
105 coercion cic:/matita/tests/coercions/church.con 1.
107 definition mapmult: \forall n:nat.\forall l:listn nat n. nat \to nat \to nat \def
108 \lambda n:nat.\lambda l:listn nat n.\lambda m,o:nat.