1 Require Export st_logic.
5 Section natural_numbers.
7 Definition N: Set := (List One).
9 Definition zero: N := (empty One).
11 Definition succ: N -> N := [n](fr One n tt).
13 Definition natrec: (P:N->Set) (P zero) ->
14 ((n:N) (P n) -> (P (succ n))) -> (n:N)(P n).
21 Definition NatFam: (P:N->Type) (P zero) ->
22 ((n:N) (P n) -> (P (succ n))) -> (n:N)(P n).
29 Definition one: N := (succ zero).
31 Definition two:N := (succ one).
37 Definition ListS := [S:Set](N -> (List S)).
39 Definition BooleS: Set := N -> Boole.
41 Definition NS := N -> N.
43 Definition trues:BooleS := [_]true.
49 Section Nat_Functions.
51 Section bounded_iteration.
53 Variable S:Set; e:S; f:S->S->S.
55 Definition bs_iter: (N -> S) -> N -> S := [s](natrec [_]S e [m](f (s m))).
57 Definition rbs_iter: (N -> S) -> N -> S := [s;n](bs_iter s (succ n)).
59 End bounded_iteration.
61 Section nat_boolean_eq.
65 Definition n_id: N -> N -> Boole := (natrec [_]N->Boole (natrec [_]Boole true [_;_]false)
66 [_;pm'](natrec [_]Boole false [n';_](pm' n'))).
68 Definition ifeq: N -> N -> S -> S -> S := [m,n;a;b](ite [_]S b a (n_id m n)).
70 Definition ifz: N -> S -> S -> S := [n;a;b](natrec [_]S a [_;_]b n).
76 Definition b_le: N -> N -> Boole := (natrec [_]N->Boole [n]true [m';p](natrec [_]Boole false [n';_](p n'))).
78 Definition LE: N -> N -> Set := [m,n](Id Boole (b_le m n) true).
80 Definition GT: N -> N -> Set := [m,n](Id Boole (b_le m n) false).
90 Theorem succ_fold: (n:N; P:N->Set) (P (succ n)) -> (P (fr One n tt)).
95 Theorem LE_fold: (m,n:N; P:Set->Set) (P (LE m n)) -> (P (Id Boole (b_le m n) true)).
106 Section nat_indipendence.
108 Theorem n_p4: (n:N) (Id N zero (succ n)) -> Empty.
110 MApply '(list_p4 One n tt).
113 Theorem n_false: (n:N; P:Set) (Id N zero (succ n)) -> P.
120 End nat_indipendence.
122 Section b_le_results.
124 Theorem le_wf: (n:N) (LE zero n).
130 Theorem le_comp_succ: (m,n:N) (LE m n) -> (LE (succ m) (succ n)).
135 Theorem le_ssucc: (m,n:N) (LE (succ m) (succ n)) -> (LE m n).
140 Theorem le_false: (n:N; P:Set) (LE (succ n) zero) -> P.
150 Theorem le_r: (n:N) (LE n n).
156 Theorem le_succ: (n:N) (LE n (succ n)).
162 Theorem le_zero: (n:N) (LE n zero) -> (Id N n zero).
165 MApply '(le_false n0).
168 Theorem le_trans: (b,c,a:N) (LE a b) -> (LE b c) -> (LE a c).
173 MApply '(le_false n).
177 MApply '(le_false b').
180 MApply 'le_comp_succ.
186 Theorem gt_wf: (n:N) (GT (succ n) zero).
192 Theorem gt_comp_succ: (m,n:N) (GT m n) -> (GT (succ m) (succ n)).
197 Theorem gt_false: (n:N; P:Set) (GT zero n) -> P.
207 Theorem le_gt: (m,n:N) (LE (succ n) m) -> (GT m n).
211 MApply '(le_false n).
217 MApply 'gt_comp_succ.
221 Theorem gt_le: (m,n:N) (GT m n) -> (LE (succ n) m).
225 MApply '(gt_false n).
228 MApply 'le_comp_succ.
230 MApply 'le_comp_succ.
234 Theorem le_gt_trans: (b,c,a:N) (LE b a) -> (GT b c) -> (GT a c).
237 MApply '(le_trans b).
241 Theorem boole_di: (b:Boole) (LOr (Id Boole b true) (Id Boole b false)).
248 Theorem le_di: (m,n:N) (LOr (LE m n) (GT m n)).
251 MApply '(boole_di (b_le m n)).
254 Theorem ble_trip: (m,n:N; P:N->Set) ((n:N) (LE n m) -> (P n)) -> ((n:N) (GT n m) -> (P n)) -> (P n).
256 MApply '(or_e (LE n m) (GT n m)).