Debian Codegraph @

doc/citp-manual/peano2.cafe

raw
1 --> ==========================================================
2 --> Proof scores for verifications of properties (including
3 --> associativity and commutativity of _+_ and _*_) about
4 --> Peano Style natural numbers with CafeOBJ/CITP
5 --> ==========================================================
6 --> :verbose on print outs an each generated goal.
7 -- :verbose on
8
9 --> ----------------------------------------------------------
10 --> Peano style natural numbers
11 --> ----------------------------------------------------------
12 mod! PNAT {
13 [ PNat ]
14 op 0 : -> PNat {constr} .
15 op s_ : PNat -> PNat {constr} .
16 }
17
18 --> ----------------------------------------------------------
19 --> PNAT with plus _+_ operation
20 --> ----------------------------------------------------------
21 mod! PNAT+ {
22 pr(PNAT)
23 op _+_ : PNat PNat -> PNat {r-assoc} .
24 eq 0 + Y:PNat = Y .
25 eq (s X:PNat) + Y:PNat = s(X + Y) .
26 }
27 --> **********************************************************
28 --> proof scores of the properties about _+_
29 --> **********************************************************
30
31 --> ==========================================================
32 select PNAT+ .
33 --> ==========================================================
34
35 --> ----------------------------------------------------------
36 :goal { eq [+rz]: M:PNat + 0 = M:PNat .
37 eq [+rs]: M:PNat + s N:PNat = s(M:PNat + N:PNat). }
38 --> ----------------------------------------------------------
39 **> we can prove two theorems together
40 :ind on (M:PNat)
41 :apply(si tc rd)
42 --> QED
43 --> ----------------------------------------------------------
44 :show proved
45
46 --> ----------------------------------------------------------
47 :goal { eq [+assoc :nonexec]:
48 (X:PNat + Y:PNat) + Z:PNat = X + (Y + Z) .}
49 --> ----------------------------------------------------------
50 :ind on (X:PNat)
51 :apply(si tc rd)
52 --> QED
53 --> ----------------------------------------------------------
54 :show discharged
55
56 --> ----------------------------------------------------------
57 :goal { eq [+comm :non-exec]: X:PNat + Y:PNat = Y + X .}
58 --> ----------------------------------------------------------
59 :use (+rz +rs)
60 :ind on (X:PNat)
61 :apply(si tc rd)
62 --> QED
63 --> ----------------------------------------------------------
64 :show proved
65
66 --> ----------------------------------------------------------
67 --> PNAT+ac
68 --> ----------------------------------------------------------
69 **> the current module is PNAT+
70 :embed [+assoc] {assoc} as PNAT+ac
71 :embed [+comm] {comm} into PNAT+ac
72 --> ----------------------------------------------------------
73 select PNAT+ac
74 show .
75 show op _+_ .
76
77 --> **********************************************************
78 --> proof scores of properties about _*_
79 --> **********************************************************
80
81 --> ----------------------------------------------------------
82 --> PNAT with _+_{assoc comm} and _*_ operation
83 --> ----------------------------------------------------------
84 mod! PNAT+ac* {
85 pr(PNAT+ac)
86 op _*_ : PNat PNat -> PNat {prec: 29 r-assoc}
87 eq 0 * Y:PNat = 0 .
88 eq s(X:PNat) * Y:PNat = Y + (X * Y) .
89 }
90
91 --> ==========================================================
92 select PNAT+ac* .
93 --> ==========================================================
94
95 --> ----------------------------------------------------------
96 :goal { eq[*disr]:
97 (X:PNat + Y:PNat) * Z:PNat = X * Z + Y * Z . }
98 --> ----------------------------------------------------------
99 :ind on (X:PNat)
100 :apply(si tc rd)
101 --> QED
102 --> ----------------------------------------------------------
103 :show proved
104
105 --> ----------------------------------------------------------
106 :goal { eq[*assoc :nonexec]:
107 (X:PNat * Y:PNat) * Z:PNat = X * (Y * Z) . }
108 --> ----------------------------------------------------------
109 :use (*disr)
110 :ind on (X:PNat)
111 :apply(si tc rd)
112 --> QED
113 --> ----------------------------------------------------------
114 :show proved
115
116 --> ----------------------------------------------------------
117 :goal { eq[*rz]: X:PNat * 0 = 0 .}
118 --> ----------------------------------------------------------
119 :ind on (X:PNat)
120 :apply (si tc rd)
121 --> QED
122 --> ----------------------------------------------------------
123 :show proved
124
125 --> ----------------------------------------------------------
126 :goal { eq[*rs]: X:PNat * s(Y:PNat) = X + (X * Y) .}
127 --> ----------------------------------------------------------
128 :ind on (X:PNat)
129 :apply(si tc rd)
130 --> QED
131 --> ----------------------------------------------------------
132 :show proved
133
134 --> ----------------------------------------------------------
135 :goal { eq[*comm :nonexec]: X:PNat * Y:PNat = Y * X .}
136 --> ----------------------------------------------------------
137 :ind on (X:PNat)
138 :use (*rz *rs)
139 :apply(si tc rd)
140 --> QED
141 --> ----------------------------------------------------------
142 :show proved
143
144 --> ----------------------------------------------------------
145 --> PNAT+ac*ac
146 --> ----------------------------------------------------------
147 **> the current module is PNAT+ac*
148 :embed [*comm] {comm} as PNAT+ac*ac
149 :embed [*assoc] {assoc} into PNAT+ac*ac
150 --> ----------------------------------------------------------
151 select PNAT+ac*ac .
152 show .
153 show op _*_
154
155 -- ==========================================================
156 --> end end end
157 -- ==========================================================