annotate record-ex.agda @ 757:a4074765abf8

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 11 Dec 2017 15:58:52 +0900
parents 0d7fa6fc5979
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
153
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 module record-ex where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 data _∨_ (A B : Set) : Set where
300
d6a6dd305da2 arrow and lambda fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 153
diff changeset
4 or1 : A → A ∨ B
d6a6dd305da2 arrow and lambda fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 153
diff changeset
5 or2 : B → A ∨ B
153
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
6
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 postulate A B C : Set
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 postulate a1 a2 a3 : A
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 postulate b1 b2 b3 : B
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
10
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 x : ( A ∨ B )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 x = or1 a1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 y : ( A ∨ B )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 y = or2 b1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
15
300
d6a6dd305da2 arrow and lambda fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 153
diff changeset
16 f : ( A ∨ B ) → A
153
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 f (or1 a) = a
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 f (or2 b) = a1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
19
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 record _∧_ (A B : Set) : Set where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 field
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 and1 : A
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 and2 : B
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
24
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 z : A ∧ B
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 z = record { and1 = a1 ; and2 = b2 }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
27
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 xa : A
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 xa = _∧_.and1 z
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 xb : B
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
31 xb = _∧_.and2 z
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
32
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 open _∧_
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
34
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 ya : A
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
36 ya = and1 z
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
37
315
0d7fa6fc5979 System T and System F
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 300
diff changeset
38 lemma1 : A ∧ B → A
0d7fa6fc5979 System T and System F
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 300
diff changeset
39 lemma1 a = and1 a
0d7fa6fc5979 System T and System F
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 300
diff changeset
40
0d7fa6fc5979 System T and System F
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 300
diff changeset
41 lemma2 : A → B → A ∧ B
0d7fa6fc5979 System T and System F
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 300
diff changeset
42 lemma2 a b = record { and1 = a ; and2 = b }
0d7fa6fc5979 System T and System F
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 300
diff changeset
43
153
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
44 open import Relation.Binary.PropositionalEquality
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
45
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
46 data Nat : Set where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
47 zero : Nat
300
d6a6dd305da2 arrow and lambda fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 153
diff changeset
48 suc : Nat → Nat
153
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
49
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
50 record Mod3 (m : Nat) : Set where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
51 field
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
52 mod3 : (suc (suc (suc m ))) ≡ m
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
53 n : Nat
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
54 n = m
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
55
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
56 open Mod3
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
57
300
d6a6dd305da2 arrow and lambda fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 153
diff changeset
58 Lemma1 : ( x : Mod3 ( suc (suc (suc (suc zero))))) ( y : Mod3 ( suc zero ) ) → n x ≡ n y
153
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 Lemma1 x y = mod3 y
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
60