Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
(* generated by Ott 0.10.14 from: ../tests/test10st.ott *)
Require Import Arith.
Require Import Bool.
Require Import List.
(** syntax *)
Definition termvar := nat.
Lemma eq_termvar: forall (x y : termvar), {x = y} + {x <> y}.
Proof.
decide equality; auto with ott_coq_equality arith.
Defined.
Hint Resolve eq_termvar : ott_coq_equality.
Definition typvar := nat.
Lemma eq_typvar: forall (x y : typvar), {x = y} + {x <> y}.
Proof.
decide equality; auto with ott_coq_equality arith.
Defined.
Hint Resolve eq_typvar : ott_coq_equality.
Inductive
T : Set :=
T_var : typvar -> T
| T_arrow : T -> T -> T
.
Inductive
t : Set :=
t_Var : termvar -> t
| t_Lam : termvar -> t -> t
| t_App : t -> t -> t
.
Definition
G : Set := list (termvar*T)
.
(** library functions *)
Fixpoint list_mem (A:Set) (eq:forall a b:A,{a=b}+{a<>b}) (x:A) (l:list A) {struct l} : bool :=
match l with
| nil => false
| cons h t => if eq h x then true else list_mem A eq x t
end.
Implicit Arguments list_mem.
Fixpoint list_minus (A:Set) (eq:forall a b:A,{a=b}+{a<>b}) (l1:list A) (l2:list A) {struct l1} : list A :=
match l1 with
| nil => nil
| cons h t => if (list_mem (A:=A) eq h l2) then list_minus A eq t l2 else cons h (list_minus A eq t l2)
end.
Implicit Arguments list_minus.
(** subrules *)
Definition is_v_of_t (t_6:t) : Prop :=
match t_6 with
| (t_Var x) => False
| (t_Lam x t5) => (True)
| (t_App t5 t') => False
end.
(** free variables *)
Fixpoint fv_t (t_6:t) : list termvar :=
match t_6 with
| (t_Var x) => (cons x nil)
| (t_Lam x t5) => ((list_minus eq_termvar (fv_t t5) (cons x nil)))
| (t_App t5 t') => (app (fv_t t5) (fv_t t'))
end.
(** substitutions *)
Fixpoint tsubst_t (t_6:t) (x5:termvar) (t__7:t) {struct t__7} : t :=
match t__7 with
| (t_Var x) => (if eq_termvar x x5 then t_6 else (t_Var x))
| (t_Lam x t5) => t_Lam x (if list_mem eq_termvar x5 (cons x nil) then t5 else (tsubst_t t_6 x5 t5))
| (t_App t5 t') => t_App (tsubst_t t_6 x5 t5) (tsubst_t t_6 x5 t')
end.
Notation G_nil := (@nil (termvar*T)).
Definition bound x T0 G :=
exists G1, exists G2,
(G = List.app G1 (List.cons (x,T0) G2)) /\
~In x (List.map (@fst termvar T) G1).
(** definitions *)
(* defns Jtype *)
Inductive
(* defn GtT *)
GtT : G -> t -> T -> Prop :=
| GtT_value_name : forall (G5:G) (x:termvar) (T5:T),
(bound x T5 G5 ) ->
GtT G5 (t_Var x) T5
| GtT_apply : forall (G5:G) (t5:t) (t':t) (T2:T) (T1:T),
GtT G5 t5 (T_arrow T1 T2) ->
GtT G5 t' T1 ->
GtT G5 (t_App t5 t') T2
| GtT_lambda : forall (G5:G) (x1:termvar) (t5:t) (T1:T) (T_5:T),
GtT (cons ( x1 , T1 ) G5 ) t5 T_5 ->
GtT G5 (t_Lam x1 t5) (T_arrow T1 T_5)
.
(* defns Jop *)
Inductive
(* defn reduce *)
reduce : t -> t -> Prop :=
| ax_app : forall (x:termvar) (t12:t) (v2:t),
is_v_of_t v2 ->
reduce (t_App (t_Lam x t12) v2) ( tsubst_t v2 x t12 )
| ctx_app_fun : forall (t1:t) (t_5:t) (t1':t),
reduce t1 t1' ->
reduce (t_App t1 t_5) (t_App t1' t_5)
| ctx_app_arg : forall (v5:t) (t1:t) (t1':t),
is_v_of_t v5 ->
reduce t1 t1' ->
reduce (t_App v5 t1) (t_App v5 t1')
.
Hint Constructors reduce GtT : rules.