Last active
August 29, 2015 14:00
-
-
Save pasberth/0818d414fe49a095e32e to your computer and use it in GitHub Desktop.
進捗
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Require Import List. | |
| Require Import Coq.Bool.Bool. | |
| Require Import Coq.Arith.EqNat. | |
| Require Import Coq.Lists.ListSet. | |
| Definition nat_eq : forall x y : nat, {x = y} + {x <> y}. | |
| decide equality. | |
| Defined. | |
| Inductive term : Set := | |
| | var : nat -> term | |
| | app : term -> term -> term | |
| | abs : nat -> term -> term. | |
| Fixpoint V (t : term) : set nat := | |
| match t with | |
| | var v => set_add nat_eq v (empty_set nat) | |
| | app m n => set_union nat_eq (V m) (V n) | |
| | abs v m => set_add nat_eq v (V m) | |
| end. | |
| Fixpoint FV (t : term) : set nat := | |
| match t with | |
| | var v => set_add nat_eq v (empty_set nat) | |
| | app m n => set_union nat_eq (V m) (V n) | |
| | abs v m => set_remove nat_eq v (V m) | |
| end. | |
| Fixpoint BV (t : term) : set nat := | |
| match t with | |
| | var v => empty_set nat | |
| | app m n => set_union nat_eq (V m) (V n) | |
| | abs v m => set_add nat_eq v (V m) | |
| end. | |
| Fixpoint substitute (x : nat) (n m : term) : term := | |
| match m with | |
| | var y => if beq_nat x y then n else var y | |
| | app q r => app (substitute x n q) (substitute x n r) | |
| | abs y q => abs y (substitute x n q) | |
| end. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment