1 (**************************************************************************)
4 (* ||A|| A project by Andrea Asperti *)
6 (* ||I|| Developers: *)
7 (* ||T|| A.Asperti, C.Sacerdoti Coen, *)
8 (* ||A|| E.Tassi, S.Zacchiroli *)
10 (* \ / This file is distributed under the terms of the *)
11 (* v GNU Lesser General Public License Version 2.1 *)
13 (**************************************************************************)
15 include "logic/connectives.ma".
16 include "datatypes/constructors.ma".
18 (* The following is a stranslation in Matita of the initial part of
19 Erik Palmgren, ``Internalizing Modified Realizability in Constructive Type
20 Theory'', Logical Methods in Computer Science, Vol 1 (2:2), 2005, pp. 1--7
22 The original Agda file realisability.agda can be found at
24 http://www.math.uu.se/~palmgren/modif/realisability.agda
33 | forall: ∀A:Type. (A → SP) → SP
34 | exist: ∀A:Type. (A → SP) → SP.
36 let rec Prop_OF_SP F ≝
40 | sand A B ⇒ Prop_OF_SP A ∧ Prop_OF_SP B
41 | sor A B ⇒ Prop_OF_SP A ∨ Prop_OF_SP B
42 | simp A B ⇒ Prop_OF_SP A → Prop_OF_SP B
43 | forall A F ⇒ ∀x:A.Prop_OF_SP (F x)
44 | exist A F ⇒ ∃x:A.Prop_OF_SP (F x)
47 inductive sigma (A:Type) (P:A → Type) : Type ≝
48 sigma_intro: ∀x:A. P x → sigma A P.
53 [ sigma_intro a _ ⇒ a].
57 match s return λs.P (pi1 ? ? s) with
58 [ sigma_intro _ p ⇒ p].
60 notation "hvbox(\Sigma ident i opt (: ty) break . p)"
61 right associative with precedence 20
62 for @{ 'sigma ${default
63 @{\lambda ${ident i} : $ty. $p}
64 @{\lambda ${ident i} . $p}}}.
66 interpretation "Sigma" 'sigma \eta.x = (sigma ? x).
68 let rec type_OF_SP F ≝
69 match F return λF.Type with
72 | sand A B ⇒ (type_OF_SP A) × (type_OF_SP B)
73 | sor A B ⇒ type_OF_SP A + type_OF_SP B
74 | simp A B ⇒ type_OF_SP A → type_OF_SP B
75 | forall A F ⇒ Πx:A.type_OF_SP (F x)
76 | exist A F ⇒ Σx:A.type_OF_SP (F x)
79 let rec modr F : type_OF_SP F → Prop ≝
80 match F return λF.type_OF_SP F → Prop with
83 | sand A B ⇒ λr.modr A (\fst r) ∧ modr B (\snd r)
92 (Prop_OF_SP A → Prop_OF_SP B) ∧
93 ∀a:type_OF_SP A. modr A a → modr B (r a)
95 λr:Πx:A.type_OF_SP (F x).∀a:A. modr (F a) (r a)
98 modr (F (pi1 ? ? r)) (pi2 ? ? r)
101 theorem correct: ∀F:SP.∀r:type_OF_SP F.modr F r → Prop_OF_SP F.
105 | split; simplify in r H2;
108 | apply (proj1 ? ? H2)
110 | apply H1;simplify in r H2;
112 | apply (proj2 ? ? H2)
115 | change in r with (type_OF_SP s + type_OF_SP s1);
116 elim r in H2 ⊢ %; simplify in H2;
117 [ left; apply H; assumption
118 | right; apply H1; assumption
130 apply (ex_intro ? ? a);
136 definition realized ≝
137 λF:SP.∃r:type_OF_SP F.modr F r.
139 theorem correct2: ∀F:SP. realized F → Prop_OF_SP F.
147 ∀A,B:Type.∀P: A → B → SP.
148 realized (forall A (λa:A. exist B (λb:B. P a b))) →
149 ∀a:A.∃b:B.Prop_OF_SP (P a b).
151 apply (correct2 (exist ? (λb:B. P a b)));
152 simplify in H; elim H; clear H;
154 apply (ex_intro ? ? (a1 a));
158 lemma true_impl_realized:
159 ∀A,B:Prop. (A → B) → realized (simp (atom A) (atom B)).
162 apply (ex_intro ? ? (λu.u));
169 (******** rules for first order logic **********************)
171 lemma elim_abs: ∀P:Prop. realized (simp abs (atom P)).
174 apply (ex_intro ? ? (λu.u));
181 lemma id_axiom: ∀F:SP. realized (simp F F).
184 apply (ex_intro ? ? (λu.u));
193 realized (simp F1 F2) → realized (simp F2 F3) → realized (simp F1 F3).
198 apply (ex_intro ? ? (λx.a1 (a x)));
204 [ intro; apply (H2 (H1 H))
205 | intros; apply (H4 ? (H3 ? H))
211 realized (simp F1 F2) → realized (simp F1 F3) → realized (simp F1 (sand F2 F3)).
215 simplify in a a1 ⊢ %;
216 apply (ex_intro ? ? (λu.〈a u, a1 u〉));
217 simplify in H2; cases H2; clear H2;
218 simplify in H; cases H; clear H;
220 [ intro; split; [ apply (H1 H) | apply (H2 H) ]
223 [ simplify; apply H3; assumption
224 | simplify; apply H4; assumption
229 (* Many more rules and examples missing, but trivial. *)