-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathAssignment06_00.v
53 lines (41 loc) · 1.51 KB
/
Assignment06_00.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
Require Export "Prop".
(* Important:
- You are NOT allowed to use the [admit] tactic
because [admit] simply admits any goal
regardless of whether it is provable or not.
But, you can leave [admit] for problems that you cannot prove.
Then you will get zero points for those problems.
- You are NOT allowed to use the following tactics.
[tauto], [intuition], [firstorder], [omega].
- Do NOT add any additional `Require Import/Export`.
*)
Inductive ex (X:Type) (P : X->Prop) : Prop :=
ex_intro : forall (witness:X) (proof: P witness), ex X P.
Notation "'exists' x , p" := (ex _ (fun x => p))
(at level 200, x ident, right associativity) : type_scope.
Notation "'exists' x : X , p" := (ex _ (fun x:X => p))
(at level 200, x ident, right associativity) : type_scope.
Theorem eq_nat_dec : forall n m : nat, {n = m} + {n <> m}.
Proof.
(* WORKED IN CLASS *)
intros n.
induction n as [|n'].
Case "n = 0".
intros m.
destruct m as [|m'].
SCase "m = 0".
left. reflexivity.
SCase "m = S m'".
right. intros contra. inversion contra.
Case "n = S n'".
intros m.
destruct m as [|m'].
SCase "m = 0".
right. intros contra. inversion contra.
SCase "m = S m'".
destruct IHn' with (m := m') as [eq | neq].
left. apply f_equal. apply eq.
right. intros Heq. inversion Heq as [Heq']. apply neq. apply Heq'.
Defined.
Definition override' {X: Type} (f: nat->X) (k:nat) (x:X) : nat->X:=
fun (k':nat) => if eq_nat_dec k k' then x else f k'.