X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fmatita%2Ftests%2Fcoercions.ma;h=20b15cd2650d8a7f7840d68696da39423af2248c;hb=2b7403dcc161d1cbf6bacd62f0868d0bc67c0fda;hp=1e92364fe61387e0918c1657f39be361050368e8;hpb=5ceecb1346e44ea4dbf6ca635efecdf155bd9258;p=helm.git diff --git a/helm/matita/tests/coercions.ma b/helm/matita/tests/coercions.ma index 1e92364fe..20b15cd26 100644 --- a/helm/matita/tests/coercions.ma +++ b/helm/matita/tests/coercions.ma @@ -1,50 +1,64 @@ +(**************************************************************************) +(* ___ *) +(* ||M|| *) +(* ||A|| A project by Andrea Asperti *) +(* ||T|| *) +(* ||I|| Developers: *) +(* ||T|| The HELM team. *) +(* ||A|| http://helm.cs.unibo.it *) +(* \ / *) +(* \ / This file is distributed under the terms of the *) +(* v GNU General Public License Version 2 *) +(* *) +(**************************************************************************) -Inductive nat : Set \def -| O : nat -| S : nat \to nat. - -Inductive list (A:Set) : Set \def -| nil : list A -| cons : A \to list A \to list A. +set "baseuri" "cic:/matita/tests/coercions/". +include "legacy/coq.ma". -Inductive bool: Set \def -| true : bool -| false : bool. +inductive pos: Set \def +| one : pos +| next : pos \to pos. +inductive nat:Set \def +| O : nat +| S : nat \to nat. +inductive int: Set \def +| positive: nat \to int +| negative : nat \to int. +inductive empty : Set \def . -let rec len (A:Set)(l:list A) on l : nat \def - match l:list with [ - nil \Rightarrow O - | (cons e tl) \Rightarrow (S (len A tl))]. +let rec pos2nat x \def + match x with + [ one \Rightarrow (S O) + | (next z) \Rightarrow S (pos2nat z)]. -let rec plus (n,m:nat) : nat \def - match n:nat with [ - O \Rightarrow m - | (S x) \Rightarrow (S (plus x m)) ]. +definition nat2int \def \lambda x. positive x. -let rec is_zero (n:nat) : bool \def - match n:nat with [ - O \Rightarrow true - | (S x) \Rightarrow false]. +coercion cic:/matita/tests/coercions/pos2nat.con. -let rec nat_eq_dec (n,m:nat) : bool \def - match n:nat with [ - O \Rightarrow - match m:nat with [ - O \Rightarrow true - | (S x) \Rightarrow false] - | (S x) \Rightarrow - match m:nat with [ - O \Rightarrow false - | (S y) \Rightarrow (nat_eq_dec x y)] - ]. +coercion cic:/matita/tests/coercions/nat2int.con. +definition fst \def \lambda x,y:int.x. -Coercion is_zero. -Coercion len. +theorem a: fst O one = fst (positive O) (next one). +reflexivity. +qed. -Print Coer. -Print Env. +definition double: + \forall f:int \to int. pos \to int +\def + \lambda f:int \to int. \lambda x : pos .f (nat2int x). + +definition double1: + \forall f:int \to int. pos \to int +\def + \lambda f:int \to int. \lambda x : pos .f (pos2nat x). +definition double2: + \forall f:int \to int. pos \to int +\def + \lambda f:int \to int. \lambda x : pos .f (nat2int (pos2nat x)). + +