updated examples to new syntax
This commit is contained in:
parent
9f5c308131
commit
0a57180cb1
4 changed files with 108 additions and 108 deletions
|
|
@ -13,64 +13,64 @@
|
||||||
-- I'd always strongly recommend including the type ascriptions for theorems
|
-- I'd always strongly recommend including the type ascriptions for theorems
|
||||||
|
|
||||||
-- a unary operation on a set `A` is a function `A -> A`
|
-- a unary operation on a set `A` is a function `A -> A`
|
||||||
unop (A : *) := A -> A;
|
def unop (A : *) := A -> A;
|
||||||
|
|
||||||
-- a binary operation on a set `A` is a function `A -> A -> A`
|
-- a binary operation on a set `A` is a function `A -> A -> A`
|
||||||
binop (A : *) := A -> A -> A;
|
def binop (A : *) := A -> A -> A;
|
||||||
|
|
||||||
-- a binary operation is associative if ...
|
-- a binary operation is associative if ...
|
||||||
assoc (A : *) (op : binop A) :=
|
def assoc (A : *) (op : binop A) :=
|
||||||
forall (a b c : A), eq A (op a (op b c)) (op (op a b) c);
|
forall (a b c : A), eq A (op a (op b c)) (op (op a b) c);
|
||||||
|
|
||||||
-- an element `e : A` is a left identity with respect to binop `op` if `∀ a, e * a = a`
|
-- an element `e : A` is a left identity with respect to binop `op` if `∀ a, e * a = a`
|
||||||
id_l (A : *) (op : binop A) (e : A) :=
|
def id_l (A : *) (op : binop A) (e : A) :=
|
||||||
forall (a : A), eq A (op e a) a;
|
forall (a : A), eq A (op e a) a;
|
||||||
|
|
||||||
-- likewise for right identity
|
-- likewise for right identity
|
||||||
id_r (A : *) (op : binop A) (e : A) :=
|
def id_r (A : *) (op : binop A) (e : A) :=
|
||||||
forall (a : A), eq A (op a e) a;
|
forall (a : A), eq A (op a e) a;
|
||||||
|
|
||||||
-- an element is an identity element if it is both a left and right identity
|
-- an element is an identity element if it is both a left and right identity
|
||||||
id (A : *) (op : binop A) (e : A) := and (id_l A op e) (id_r A op e);
|
def id (A : *) (op : binop A) (e : A) := and (id_l A op e) (id_r A op e);
|
||||||
|
|
||||||
-- b is a left inverse for a if `b * a = e`
|
-- b is a left inverse for a if `b * a = e`
|
||||||
-- NOTE: we don't require `e` to be an identity in this definition.
|
-- NOTE: we don't require `e` to be an identity in this definition.
|
||||||
-- this definition is purely for convenience's sake
|
-- this definition is purely for convenience's sake
|
||||||
inv_l (A : *) (op : binop A) (e : A) (a b : A) := eq A (op b a) e;
|
def inv_l (A : *) (op : binop A) (e : A) (a b : A) := eq A (op b a) e;
|
||||||
|
|
||||||
-- likewise for right inverse
|
-- likewise for right inverse
|
||||||
inv_r (A : *) (op : binop A) (e : A) (a b : A) := eq A (op a b) e;
|
def inv_r (A : *) (op : binop A) (e : A) (a b : A) := eq A (op a b) e;
|
||||||
|
|
||||||
-- and full-on inverse
|
-- and full-on inverse
|
||||||
inv (A : *) (op : binop A) (e : A) (a b : A) := and (inv_l A op e a b) (inv_r A op e a b);
|
def inv (A : *) (op : binop A) (e : A) (a b : A) := and (inv_l A op e a b) (inv_r A op e a b);
|
||||||
|
|
||||||
-- --------------------------------------------------------------------------------------------------------------
|
-- --------------------------------------------------------------------------------------------------------------
|
||||||
-- | ALGEBRAIC STRUCTURES |
|
-- | ALGEBRAIC STRUCTURES |
|
||||||
-- --------------------------------------------------------------------------------------------------------------
|
-- --------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
-- a set `S` with binary operation `op` is a semigroup if its operation is associative
|
-- a set `S` with binary operation `op` is a semigroup if its operation is associative
|
||||||
semigroup (S : *) (op : binop S) : * := assoc S op;
|
def semigroup (S : *) (op : binop S) : * := assoc S op;
|
||||||
|
|
||||||
-- a set `M` with binary operation `op` and element `e` is a monoid
|
-- a set `M` with binary operation `op` and element `e` is a monoid
|
||||||
monoid (M : *) (op : binop M) (e : M) : * :=
|
def monoid (M : *) (op : binop M) (e : M) : * :=
|
||||||
and (semigroup M op) (id M op e);
|
and (semigroup M op) (id M op e);
|
||||||
|
|
||||||
-- some "getters" for `monoid` so we don't have to do a bunch of very verbose
|
-- some "getters" for `monoid` so we don't have to do a bunch of very verbose
|
||||||
-- and-eliminations every time we want to use something
|
-- and-eliminations every time we want to use something
|
||||||
id_lm (M : *) (op : binop M) (e : M) (Hmonoid : monoid M op e) : id_l M op e :=
|
def id_lm (M : *) (op : binop M) (e : M) (Hmonoid : monoid M op e) : id_l M op e :=
|
||||||
and_elim_l (id_l M op e) (id_r M op e)
|
and_elim_l (id_l M op e) (id_r M op e)
|
||||||
(and_elim_r (semigroup M op) (id M op e) Hmonoid);
|
(and_elim_r (semigroup M op) (id M op e) Hmonoid);
|
||||||
|
|
||||||
id_rm (M : *) (op : binop M) (e : M) (Hmonoid : monoid M op e) : id_r M op e :=
|
def id_rm (M : *) (op : binop M) (e : M) (Hmonoid : monoid M op e) : id_r M op e :=
|
||||||
and_elim_r (id_l M op e) (id_r M op e)
|
and_elim_r (id_l M op e) (id_r M op e)
|
||||||
(and_elim_r (semigroup M op) (id M op e) Hmonoid);
|
(and_elim_r (semigroup M op) (id M op e) Hmonoid);
|
||||||
|
|
||||||
assoc_m (M : *) (op : binop M) (e : M) (Hmonoid : monoid M op e) : assoc M op :=
|
def assoc_m (M : *) (op : binop M) (e : M) (Hmonoid : monoid M op e) : assoc M op :=
|
||||||
and_elim_l (semigroup M op) (id M op e) Hmonoid;
|
and_elim_l (semigroup M op) (id M op e) Hmonoid;
|
||||||
|
|
||||||
-- now we can prove that, for any monoid, if `a` is a left identity, then it
|
-- now we can prove that, for any monoid, if `a` is a left identity, then it
|
||||||
-- must be "the" identity
|
-- must be "the" identity
|
||||||
monoid_id_l_implies_identity
|
def monoid_id_l_implies_identity
|
||||||
(M : *) (op : binop M) (e : M) (Hmonoid : monoid M op e)
|
(M : *) (op : binop M) (e : M) (Hmonoid : monoid M op e)
|
||||||
(a : M) (H : id_l M op a) : eq M a e :=
|
(a : M) (H : id_l M op a) : eq M a e :=
|
||||||
-- WTS a = a * e = e
|
-- WTS a = a * e = e
|
||||||
|
|
@ -86,7 +86,7 @@ monoid_id_l_implies_identity
|
||||||
(H e);
|
(H e);
|
||||||
|
|
||||||
-- the analogous result for right identities
|
-- the analogous result for right identities
|
||||||
monoid_id_r_implies_identity
|
def monoid_id_r_implies_identity
|
||||||
(M : *) (op : binop M) (e : M) (Hmonoid : monoid M op e)
|
(M : *) (op : binop M) (e : M) (Hmonoid : monoid M op e)
|
||||||
(a : M) (H : id_r M op a) : eq M a e :=
|
(a : M) (H : id_r M op a) : eq M a e :=
|
||||||
-- this time, we'll show `a = e * a = e`
|
-- this time, we'll show `a = e * a = e`
|
||||||
|
|
@ -102,36 +102,36 @@ monoid_id_r_implies_identity
|
||||||
|
|
||||||
|
|
||||||
-- groups are just monoids with inverses
|
-- groups are just monoids with inverses
|
||||||
has_inverses (G : *) (op : binop G) (e : G) (i : unop G) : * :=
|
def has_inverses (G : *) (op : binop G) (e : G) (i : unop G) : * :=
|
||||||
forall (a : G), inv G op e a (i a);
|
forall (a : G), inv G op e a (i a);
|
||||||
|
|
||||||
group (G : *) (op : binop G) (e : G) (i : unop G) : * :=
|
def group (G : *) (op : binop G) (e : G) (i : unop G) : * :=
|
||||||
and (monoid G op e)
|
and (monoid G op e)
|
||||||
(has_inverses G op e i);
|
(has_inverses G op e i);
|
||||||
|
|
||||||
-- more "getters"
|
-- more "getters"
|
||||||
monoid_g (G : *) (op : binop G) (e : G) (i : unop G) (Hgroup : group G op e i) : monoid G op e :=
|
def monoid_g (G : *) (op : binop G) (e : G) (i : unop G) (Hgroup : group G op e i) : monoid G op e :=
|
||||||
and_elim_l (monoid G op e) (has_inverses G op e i) Hgroup;
|
and_elim_l (monoid G op e) (has_inverses G op e i) Hgroup;
|
||||||
|
|
||||||
assoc_g (G : *) (op : binop G) (e : G) (i : unop G) (Hgroup : group G op e i) : assoc G op :=
|
def assoc_g (G : *) (op : binop G) (e : G) (i : unop G) (Hgroup : group G op e i) : assoc G op :=
|
||||||
assoc_m G op e (monoid_g G op e i Hgroup);
|
assoc_m G op e (monoid_g G op e i Hgroup);
|
||||||
|
|
||||||
id_lg (G : *) (op : binop G) (e : G) (i : unop G) (Hgroup : group G op e i) : id_l G op e :=
|
def id_lg (G : *) (op : binop G) (e : G) (i : unop G) (Hgroup : group G op e i) : id_l G op e :=
|
||||||
id_lm G op e (and_elim_l (monoid G op e) (has_inverses G op e i) Hgroup);
|
id_lm G op e (and_elim_l (monoid G op e) (has_inverses G op e i) Hgroup);
|
||||||
|
|
||||||
id_rg (G : *) (op : binop G) (e : G) (i : unop G) (Hgroup : group G op e i) : id_r G op e :=
|
def id_rg (G : *) (op : binop G) (e : G) (i : unop G) (Hgroup : group G op e i) : id_r G op e :=
|
||||||
id_rm G op e (and_elim_l (monoid G op e) (has_inverses G op e i) Hgroup);
|
id_rm G op e (and_elim_l (monoid G op e) (has_inverses G op e i) Hgroup);
|
||||||
|
|
||||||
inv_g (G : *) (op : binop G) (e : G) (i : unop G) (Hgroup : group G op e i) : forall (a : G), inv G op e a (i a) :=
|
def inv_g (G : *) (op : binop G) (e : G) (i : unop G) (Hgroup : group G op e i) : forall (a : G), inv G op e a (i a) :=
|
||||||
and_elim_r (monoid G op e) (has_inverses G op e i) Hgroup;
|
and_elim_r (monoid G op e) (has_inverses G op e i) Hgroup;
|
||||||
|
|
||||||
inv_lg (G : *) (op : binop G) (e : G) (i : unop G) (Hgroup : group G op e i) (a : G) : inv_l G op e a (i a) :=
|
def inv_lg (G : *) (op : binop G) (e : G) (i : unop G) (Hgroup : group G op e i) (a : G) : inv_l G op e a (i a) :=
|
||||||
and_elim_l (inv_l G op e a (i a)) (inv_r G op e a (i a)) (inv_g G op e i Hgroup a);
|
and_elim_l (inv_l G op e a (i a)) (inv_r G op e a (i a)) (inv_g G op e i Hgroup a);
|
||||||
|
|
||||||
inv_rg (G : *) (op : binop G) (e : G) (i : unop G) (Hgroup : group G op e i) (a : G) : inv_r G op e a (i a) :=
|
def inv_rg (G : *) (op : binop G) (e : G) (i : unop G) (Hgroup : group G op e i) (a : G) : inv_r G op e a (i a) :=
|
||||||
and_elim_r (inv_l G op e a (i a)) (inv_r G op e a (i a)) (inv_g G op e i Hgroup a);
|
and_elim_r (inv_l G op e a (i a)) (inv_r G op e a (i a)) (inv_g G op e i Hgroup a);
|
||||||
|
|
||||||
left_inv_unique (G : *) (op : binop G) (e : G) (i : unop G) (Hgroup : group G op e i) (a b : G) (h : inv_l G op e a b) : eq G b (i a) :=
|
def left_inv_unique (G : *) (op : binop G) (e : G) (i : unop G) (Hgroup : group G op e i) (a b : G) (h : inv_l G op e a b) : eq G b (i a) :=
|
||||||
-- b = b * e
|
-- b = b * e
|
||||||
-- = b * (a * a^-1)
|
-- = b * (a * a^-1)
|
||||||
-- = (b * a) * a^-1
|
-- = (b * a) * a^-1
|
||||||
|
|
|
||||||
|
|
@ -2,23 +2,23 @@
|
||||||
|
|
||||||
-- excluded middle!
|
-- excluded middle!
|
||||||
-- P ∨ ~P
|
-- P ∨ ~P
|
||||||
em (P : *) : or (P) (not P) := axiom;
|
axiom em (P : *) : or (P) (not P);
|
||||||
|
|
||||||
-- ~~P => P
|
-- ~~P => P
|
||||||
dne (P : *) (nnp : not (not P)) : P :=
|
def dne (P : *) (nnp : not (not P)) : P :=
|
||||||
or_elim P (not P) P (em P)
|
or_elim P (not P) P (em P)
|
||||||
(fun (p : P) => p)
|
(fun (p : P) => p)
|
||||||
(fun (np : not P) => nnp np P);
|
(fun (np : not P) => nnp np P);
|
||||||
|
|
||||||
-- ((P => Q) => P) => P
|
-- ((P => Q) => P) => P
|
||||||
peirce (P Q : *) (h : (P -> Q) -> P) : P :=
|
def peirce (P Q : *) (h : (P -> Q) -> P) : P :=
|
||||||
or_elim P (not P) P (em P)
|
or_elim P (not P) P (em P)
|
||||||
(fun (p : P) => p)
|
(fun (p : P) => p)
|
||||||
(fun (np : not P) => h (fun (p : P) => np p Q));
|
(fun (np : not P) => h (fun (p : P) => np p Q));
|
||||||
|
|
||||||
|
|
||||||
-- ~(A ∧ B) => ~A ∨ ~B
|
-- ~(A ∧ B) => ~A ∨ ~B
|
||||||
de_morgan4 (A B : *) (h : not (and A B)) : or (not A) (not B) :=
|
def de_morgan4 (A B : *) (h : not (and A B)) : or (not A) (not B) :=
|
||||||
or_elim A (not A) (or (not A) (not B)) (em A)
|
or_elim A (not A) (or (not A) (not B)) (em A)
|
||||||
(fun (a : A) =>
|
(fun (a : A) =>
|
||||||
or_elim B (not B) (or (not A) (not B)) (em B)
|
or_elim B (not B) (or (not A) (not B)) (em B)
|
||||||
|
|
|
||||||
|
|
@ -1,44 +1,44 @@
|
||||||
-- False
|
-- False
|
||||||
|
|
||||||
false : * := forall (A : *), A;
|
def false : * := forall (A : *), A;
|
||||||
|
|
||||||
-- no introduction rule
|
-- no introduction rule
|
||||||
|
|
||||||
-- elimination rule
|
-- elimination rule
|
||||||
false_elim (A : *) (contra : false) : A := contra A;
|
def false_elim (A : *) (contra : false) : A := contra A;
|
||||||
|
|
||||||
-- --------------------------------------------------------------------------------------------------------------
|
-- --------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
-- Negation
|
-- Negation
|
||||||
|
|
||||||
not (A : *) : * := A -> false;
|
def not (A : *) : * := A -> false;
|
||||||
|
|
||||||
-- introduction rule (kinda just the definition)
|
-- introduction rule (kinda just the definition)
|
||||||
not_intro (A : *) (h : A -> false) : not A := h;
|
def not_intro (A : *) (h : A -> false) : not A := h;
|
||||||
|
|
||||||
-- elimination rule
|
-- elimination rule
|
||||||
not_elim (A B : *) (a : A) (na : not A) : B := na a B;
|
def not_elim (A B : *) (a : A) (na : not A) : B := na a B;
|
||||||
|
|
||||||
-- can introduce double negation (can't eliminate it as that isn't constructive)
|
-- can introduce double negation (can't eliminate it as that isn't constructive)
|
||||||
double_neg_intro (A : *) (a : A) : not (not A) :=
|
def double_neg_intro (A : *) (a : A) : not (not A) :=
|
||||||
fun (notA : not A) => notA a;
|
fun (notA : not A) => notA a;
|
||||||
|
|
||||||
-- --------------------------------------------------------------------------------------------------------------
|
-- --------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
-- Conjunction
|
-- Conjunction
|
||||||
|
|
||||||
and (A B : *) : * := forall (C : *), (A -> B -> C) -> C;
|
def and (A B : *) : * := forall (C : *), (A -> B -> C) -> C;
|
||||||
|
|
||||||
-- introduction rule
|
-- introduction rule
|
||||||
and_intro (A B : *) (a : A) (b : B) : and A B :=
|
def and_intro (A B : *) (a : A) (b : B) : and A B :=
|
||||||
fun (C : *) (H : A -> B -> C) => H a b;
|
fun (C : *) (H : A -> B -> C) => H a b;
|
||||||
|
|
||||||
-- left elimination rule
|
-- left elimination rule
|
||||||
and_elim_l (A B : *) (ab : and A B) : A :=
|
def and_elim_l (A B : *) (ab : and A B) : A :=
|
||||||
ab A (fun (a : A) (b : B) => a);
|
ab A (fun (a : A) (b : B) => a);
|
||||||
|
|
||||||
-- right elimination rule
|
-- right elimination rule
|
||||||
and_elim_r (A B : *) (ab : and A B) : B :=
|
def and_elim_r (A B : *) (ab : and A B) : B :=
|
||||||
ab B (fun (a : A) (b : B) => b);
|
ab B (fun (a : A) (b : B) => b);
|
||||||
|
|
||||||
-- --------------------------------------------------------------------------------------------------------------
|
-- --------------------------------------------------------------------------------------------------------------
|
||||||
|
|
@ -46,18 +46,18 @@ and_elim_r (A B : *) (ab : and A B) : B :=
|
||||||
-- Disjunction
|
-- Disjunction
|
||||||
|
|
||||||
-- 2nd order disjunction
|
-- 2nd order disjunction
|
||||||
or (A B : *) : * := forall (C : *), (A -> C) -> (B -> C) -> C;
|
def or (A B : *) : * := forall (C : *), (A -> C) -> (B -> C) -> C;
|
||||||
|
|
||||||
-- left introduction rule
|
-- left introduction rule
|
||||||
or_intro_l (A B : *) (a : A) : or A B :=
|
def or_intro_l (A B : *) (a : A) : or A B :=
|
||||||
fun (C : *) (ha : A -> C) (hb : B -> C) => ha a;
|
fun (C : *) (ha : A -> C) (hb : B -> C) => ha a;
|
||||||
|
|
||||||
-- right introduction rule
|
-- right introduction rule
|
||||||
or_intro_r (A B : *) (b : B) : or A B :=
|
def or_intro_r (A B : *) (b : B) : or A B :=
|
||||||
fun (C : *) (ha : A -> C) (hb : B -> C) => hb b;
|
fun (C : *) (ha : A -> C) (hb : B -> C) => hb b;
|
||||||
|
|
||||||
-- elimination rule (kinda just the definition)
|
-- elimination rule (kinda just the definition)
|
||||||
or_elim (A B C : *) (ab : or A B) (ha : A -> C) (hb : B -> C) : C :=
|
def or_elim (A B C : *) (ab : or A B) (ha : A -> C) (hb : B -> C) : C :=
|
||||||
ab C ha hb;
|
ab C ha hb;
|
||||||
|
|
||||||
-- --------------------------------------------------------------------------------------------------------------
|
-- --------------------------------------------------------------------------------------------------------------
|
||||||
|
|
@ -65,14 +65,14 @@ or_elim (A B C : *) (ab : or A B) (ha : A -> C) (hb : B -> C) : C :=
|
||||||
-- Existential
|
-- Existential
|
||||||
|
|
||||||
-- 2nd order existential
|
-- 2nd order existential
|
||||||
exists (A : *) (P : A -> *) : * := forall (C : *), (forall (x : A), P x -> C) -> C;
|
def exists (A : *) (P : A -> *) : * := forall (C : *), (forall (x : A), P x -> C) -> C;
|
||||||
|
|
||||||
-- introduction rule
|
-- introduction rule
|
||||||
exists_intro (A : *) (P : A -> *) (a : A) (h : P a) : exists A P :=
|
def exists_intro (A : *) (P : A -> *) (a : A) (h : P a) : exists A P :=
|
||||||
fun (C : *) (g : forall (x : A), P x -> C) => g a h;
|
fun (C : *) (g : forall (x : A), P x -> C) => g a h;
|
||||||
|
|
||||||
-- elimination rule (kinda just the definition)
|
-- elimination rule (kinda just the definition)
|
||||||
exists_elim (A B : *) (P : A -> *) (ex_a : exists A P) (h : forall (a : A), P a -> B) : B :=
|
def exists_elim (A B : *) (P : A -> *) (ex_a : exists A P) (h : forall (a : A), P a -> B) : B :=
|
||||||
ex_a B h;
|
ex_a B h;
|
||||||
|
|
||||||
-- --------------------------------------------------------------------------------------------------------------
|
-- --------------------------------------------------------------------------------------------------------------
|
||||||
|
|
@ -80,34 +80,34 @@ exists_elim (A B : *) (P : A -> *) (ex_a : exists A P) (h : forall (a : A), P a
|
||||||
-- Universal
|
-- Universal
|
||||||
|
|
||||||
-- 2nd order universal (just ∏, including it for completeness)
|
-- 2nd order universal (just ∏, including it for completeness)
|
||||||
all (A : *) (P : A -> *) : * := forall (a : A), P a;
|
def all (A : *) (P : A -> *) : * := forall (a : A), P a;
|
||||||
|
|
||||||
-- introduction rule
|
-- introduction rule
|
||||||
all_intro (A : *) (P : A -> *) (h : forall (a : A), P a) : all A P := h;
|
def all_intro (A : *) (P : A -> *) (h : forall (a : A), P a) : all A P := h;
|
||||||
|
|
||||||
-- elimination rule
|
-- elimination rule
|
||||||
all_elim (A : *) (P : A -> *) (h_all : all A P) (a : A) : P a := h_all a;
|
def all_elim (A : *) (P : A -> *) (h_all : all A P) (a : A) : P a := h_all a;
|
||||||
|
|
||||||
-- --------------------------------------------------------------------------------------------------------------
|
-- --------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
-- Equality
|
-- Equality
|
||||||
|
|
||||||
-- 2nd order Leibniz equality
|
-- 2nd order Leibniz equality
|
||||||
eq (A : *) (x y : A) := forall (P : A -> *), P x -> P y;
|
def eq (A : *) (x y : A) := forall (P : A -> *), P x -> P y;
|
||||||
|
|
||||||
-- equality is reflexive
|
-- equality is reflexive
|
||||||
eq_refl (A : *) (x : A) : eq A x x := fun (P : A -> *) (Hx : P x) => Hx;
|
def eq_refl (A : *) (x : A) : eq A x x := fun (P : A -> *) (Hx : P x) => Hx;
|
||||||
|
|
||||||
-- equality is symmetric
|
-- equality is symmetric
|
||||||
eq_sym (A : *) (x y : A) (Hxy : eq A x y) : eq A y x := fun (P : A -> *) (Hy : P y) =>
|
def eq_sym (A : *) (x y : A) (Hxy : eq A x y) : eq A y x := fun (P : A -> *) (Hy : P y) =>
|
||||||
Hxy (fun (z : A) => P z -> P x) (fun (Hx : P x) => Hx) Hy;
|
Hxy (fun (z : A) => P z -> P x) (fun (Hx : P x) => Hx) Hy;
|
||||||
|
|
||||||
-- equality is transitive
|
-- equality is transitive
|
||||||
eq_trans (A : *) (x y z : A) (Hxy : eq A x y) (Hyz : eq A y z) : eq A x z := fun (P : A -> *) (Hx : P x) =>
|
def eq_trans (A : *) (x y z : A) (Hxy : eq A x y) (Hyz : eq A y z) : eq A x z := fun (P : A -> *) (Hx : P x) =>
|
||||||
Hyz P (Hxy P Hx);
|
Hyz P (Hxy P Hx);
|
||||||
|
|
||||||
-- equality is a universal congruence
|
-- equality is a universal congruence
|
||||||
eq_cong (A B : *) (x y : A) (f : A -> B) (H : eq A x y) : eq B (f x) (f y) :=
|
def eq_cong (A B : *) (x y : A) (f : A -> B) (H : eq A x y) : eq B (f x) (f y) :=
|
||||||
fun (P : B -> *) (Hfx : P (f x)) =>
|
fun (P : B -> *) (Hfx : P (f x)) =>
|
||||||
H (fun (a : A) => P (f a)) Hfx;
|
H (fun (a : A) => P (f a)) Hfx;
|
||||||
|
|
||||||
|
|
@ -116,20 +116,20 @@ eq_cong (A B : *) (x y : A) (f : A -> B) (H : eq A x y) : eq B (f x) (f y) :=
|
||||||
-- Some logic theorems
|
-- Some logic theorems
|
||||||
|
|
||||||
-- ~(A ∨ B) => ~A ∧ ~B
|
-- ~(A ∨ B) => ~A ∧ ~B
|
||||||
de_morgan1 (A B : *) (h : not (or A B)) : and (not A) (not B) :=
|
def de_morgan1 (A B : *) (h : not (or A B)) : and (not A) (not B) :=
|
||||||
and_intro (not A) (not B)
|
and_intro (not A) (not B)
|
||||||
(fun (a : A) => h (or_intro_l A B a))
|
(fun (a : A) => h (or_intro_l A B a))
|
||||||
(fun (b : B) => h (or_intro_r A B b));
|
(fun (b : B) => h (or_intro_r A B b));
|
||||||
|
|
||||||
-- ~A ∧ ~B => ~(A ∨ B)
|
-- ~A ∧ ~B => ~(A ∨ B)
|
||||||
de_morgan2 (A B : *) (h : and (not A) (not B)) : not (or A B) :=
|
def de_morgan2 (A B : *) (h : and (not A) (not B)) : not (or A B) :=
|
||||||
fun (contra : or A B) =>
|
fun (contra : or A B) =>
|
||||||
or_elim A B false contra
|
or_elim A B false contra
|
||||||
(and_elim_l (not A) (not B) h)
|
(and_elim_l (not A) (not B) h)
|
||||||
(and_elim_r (not A) (not B) h);
|
(and_elim_r (not A) (not B) h);
|
||||||
|
|
||||||
-- ~A ∨ ~B => ~(A ∧ B)
|
-- ~A ∨ ~B => ~(A ∧ B)
|
||||||
de_morgan3 (A B : *) (h : or (not A) (not B)) : not (and A B) :=
|
def de_morgan3 (A B : *) (h : or (not A) (not B)) : not (and A B) :=
|
||||||
fun (contra : and A B) =>
|
fun (contra : and A B) =>
|
||||||
or_elim (not A) (not B) false h
|
or_elim (not A) (not B) false h
|
||||||
(fun (na : not A) => na (and_elim_l A B contra))
|
(fun (na : not A) => na (and_elim_l A B contra))
|
||||||
|
|
@ -138,19 +138,19 @@ de_morgan3 (A B : *) (h : or (not A) (not B)) : not (and A B) :=
|
||||||
-- the last one (~(A ∧ B) => ~A ∨ ~B) is not possible constructively
|
-- the last one (~(A ∧ B) => ~A ∨ ~B) is not possible constructively
|
||||||
|
|
||||||
-- A ∧ B => B ∧ A
|
-- A ∧ B => B ∧ A
|
||||||
and_comm (A B : *) (h : and A B) : and B A :=
|
def and_comm (A B : *) (h : and A B) : and B A :=
|
||||||
and_intro B A
|
and_intro B A
|
||||||
(and_elim_r A B h)
|
(and_elim_r A B h)
|
||||||
(and_elim_l A B h);
|
(and_elim_l A B h);
|
||||||
|
|
||||||
-- A ∨ B => B ∨ A
|
-- A ∨ B => B ∨ A
|
||||||
or_comm (A B : *) (h : or A B) : or B A :=
|
def or_comm (A B : *) (h : or A B) : or B A :=
|
||||||
or_elim A B (or B A) h
|
or_elim A B (or B A) h
|
||||||
(fun (a : A) => or_intro_r B A a)
|
(fun (a : A) => or_intro_r B A a)
|
||||||
(fun (b : B) => or_intro_l B A b);
|
(fun (b : B) => or_intro_l B A b);
|
||||||
|
|
||||||
-- A ∧ (B ∧ C) => (A ∧ B) ∧ C
|
-- A ∧ (B ∧ C) => (A ∧ B) ∧ C
|
||||||
and_assoc_l (A B C : *) (h : and A (and B C)) : and (and A B) C :=
|
def and_assoc_l (A B C : *) (h : and A (and B C)) : and (and A B) C :=
|
||||||
let (a := (and_elim_l A (and B C) h))
|
let (a := (and_elim_l A (and B C) h))
|
||||||
(bc := (and_elim_r A (and B C) h))
|
(bc := (and_elim_r A (and B C) h))
|
||||||
(b := (and_elim_l B C bc))
|
(b := (and_elim_l B C bc))
|
||||||
|
|
@ -160,7 +160,7 @@ and_assoc_l (A B C : *) (h : and A (and B C)) : and (and A B) C :=
|
||||||
end;
|
end;
|
||||||
|
|
||||||
-- (A ∧ B) ∧ C => A ∧ (B ∧ C)
|
-- (A ∧ B) ∧ C => A ∧ (B ∧ C)
|
||||||
and_assoc_r (A B C : *) (h : and (and A B) C) : and A (and B C) :=
|
def and_assoc_r (A B C : *) (h : and (and A B) C) : and A (and B C) :=
|
||||||
let (ab := and_elim_l (and A B) C h)
|
let (ab := and_elim_l (and A B) C h)
|
||||||
(a := and_elim_l A B ab)
|
(a := and_elim_l A B ab)
|
||||||
(b := and_elim_r A B ab)
|
(b := and_elim_r A B ab)
|
||||||
|
|
@ -170,7 +170,7 @@ and_assoc_r (A B C : *) (h : and (and A B) C) : and A (and B C) :=
|
||||||
end;
|
end;
|
||||||
|
|
||||||
-- A ∨ (B ∨ C) => (A ∨ B) ∨ C
|
-- A ∨ (B ∨ C) => (A ∨ B) ∨ C
|
||||||
or_assoc_l (A B C : *) (h : or A (or B C)) : or (or A B) C :=
|
def or_assoc_l (A B C : *) (h : or A (or B C)) : or (or A B) C :=
|
||||||
or_elim A (or B C) (or (or A B) C) h
|
or_elim A (or B C) (or (or A B) C) h
|
||||||
(fun (a : A) => or_intro_l (or A B) C (or_intro_l A B a))
|
(fun (a : A) => or_intro_l (or A B) C (or_intro_l A B a))
|
||||||
(fun (g : or B C) =>
|
(fun (g : or B C) =>
|
||||||
|
|
@ -179,7 +179,7 @@ or_assoc_l (A B C : *) (h : or A (or B C)) : or (or A B) C :=
|
||||||
(fun (c : C) => or_intro_r (or A B) C c));
|
(fun (c : C) => or_intro_r (or A B) C c));
|
||||||
|
|
||||||
-- (A ∨ B) ∨ C => A ∨ (B ∨ C)
|
-- (A ∨ B) ∨ C => A ∨ (B ∨ C)
|
||||||
or_assoc_r (A B C : *) (h : or (or A B) C) : or A (or B C) :=
|
def or_assoc_r (A B C : *) (h : or (or A B) C) : or A (or B C) :=
|
||||||
or_elim (or A B) C (or A (or B C)) h
|
or_elim (or A B) C (or A (or B C)) h
|
||||||
(fun (g : or A B) =>
|
(fun (g : or A B) =>
|
||||||
or_elim A B (or A (or B C)) g
|
or_elim A B (or A (or B C)) g
|
||||||
|
|
@ -188,7 +188,7 @@ or_assoc_r (A B C : *) (h : or (or A B) C) : or A (or B C) :=
|
||||||
(fun (c : C) => or_intro_r A (or B C) (or_intro_r B C c));
|
(fun (c : C) => or_intro_r A (or B C) (or_intro_r B C c));
|
||||||
|
|
||||||
-- A ∧ (B ∨ C) => A ∧ B ∨ A ∧ C
|
-- A ∧ (B ∨ C) => A ∧ B ∨ A ∧ C
|
||||||
and_distrib_l_or (A B C : *) (h : and A (or B C)) : or (and A B) (and A C) :=
|
def and_distrib_l_or (A B C : *) (h : and A (or B C)) : or (and A B) (and A C) :=
|
||||||
or_elim B C (or (and A B) (and A C)) (and_elim_r A (or B C) h)
|
or_elim B C (or (and A B) (and A C)) (and_elim_r A (or B C) h)
|
||||||
(fun (b : B) => or_intro_l (and A B) (and A C)
|
(fun (b : B) => or_intro_l (and A B) (and A C)
|
||||||
(and_intro A B (and_elim_l A (or B C) h) b))
|
(and_intro A B (and_elim_l A (or B C) h) b))
|
||||||
|
|
@ -196,7 +196,7 @@ and_distrib_l_or (A B C : *) (h : and A (or B C)) : or (and A B) (and A C) :=
|
||||||
(and_intro A C (and_elim_l A (or B C) h) c));
|
(and_intro A C (and_elim_l A (or B C) h) c));
|
||||||
|
|
||||||
-- A ∧ B ∨ A ∧ C => A ∧ (B ∨ C)
|
-- A ∧ B ∨ A ∧ C => A ∧ (B ∨ C)
|
||||||
and_factor_l_or (A B C : *) (h : or (and A B) (and A C)) : and A (or B C) :=
|
def and_factor_l_or (A B C : *) (h : or (and A B) (and A C)) : and A (or B C) :=
|
||||||
or_elim (and A B) (and A C) (and A (or B C)) h
|
or_elim (and A B) (and A C) (and A (or B C)) h
|
||||||
(fun (ab : and A B) => and_intro A (or B C)
|
(fun (ab : and A B) => and_intro A (or B C)
|
||||||
(and_elim_l A B ab)
|
(and_elim_l A B ab)
|
||||||
|
|
@ -207,9 +207,9 @@ and_factor_l_or (A B C : *) (h : or (and A B) (and A C)) : and A (or B C) :=
|
||||||
|
|
||||||
-- Thanks Quinn!
|
-- Thanks Quinn!
|
||||||
-- A ∨ B => ~B => A
|
-- A ∨ B => ~B => A
|
||||||
disj_syllog (A B : *) (nb : not B) (hor : or A B) : A :=
|
def disj_syllog (A B : *) (nb : not B) (hor : or A B) : A :=
|
||||||
or_elim A B A hor (fun (a : A) => a) (fun (b : B) => nb b A);
|
or_elim A B A hor (fun (a : A) => a) (fun (b : B) => nb b A);
|
||||||
|
|
||||||
-- (A => B) => ~B => ~A
|
-- (A => B) => ~B => ~A
|
||||||
contrapositive (A B : *) (f : A -> B) (nb : not B) : not A :=
|
def contrapositive (A B : *) (f : A -> B) (nb : not B) : not A :=
|
||||||
fun (a : A) => nb (f a);
|
fun (a : A) => nb (f a);
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
@include logic.pg
|
@include logic.pg
|
||||||
@include algebra.pg
|
@include algebra.pg
|
||||||
|
|
||||||
comp (A B C : *) (g : B -> C) (f : A -> B) (x : A) : C :=
|
def comp (A B C : *) (g : B -> C) (f : A -> B) (x : A) : C :=
|
||||||
g (f x);
|
g (f x);
|
||||||
|
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
@ -24,7 +24,7 @@ comp (A B C : *) (g : B -> C) (f : A -> B) (x : A) : C :=
|
||||||
-- defined is a value of the asserted type. For example, we will use the axiom
|
-- defined is a value of the asserted type. For example, we will use the axiom
|
||||||
-- system to assert the existence of a type of natural numbers
|
-- system to assert the existence of a type of natural numbers
|
||||||
|
|
||||||
nat : * := axiom;
|
axiom nat : *;
|
||||||
|
|
||||||
-- As you can imagine, this can be risky. For instance, there's nothing stopping
|
-- As you can imagine, this can be risky. For instance, there's nothing stopping
|
||||||
-- us from saying
|
-- us from saying
|
||||||
|
|
@ -47,21 +47,21 @@ nat : * := axiom;
|
||||||
-- (https://en.wikipedia.org/wiki/Peano_axioms).
|
-- (https://en.wikipedia.org/wiki/Peano_axioms).
|
||||||
|
|
||||||
-- axiom 1: 0 is a natural number
|
-- axiom 1: 0 is a natural number
|
||||||
zero : nat := axiom;
|
axiom zero : nat;
|
||||||
|
|
||||||
-- axiom 6: For every n, S n is a natural number.
|
-- axiom 6: For every n, S n is a natural number.
|
||||||
suc (n : nat) : nat := axiom;
|
axiom suc (n : nat) : nat;
|
||||||
|
|
||||||
-- axiom 7: If S n = S m, then n = m.
|
-- axiom 7: If S n = S m, then n = m.
|
||||||
suc_inj : forall (n m : nat), eq nat (suc n) (suc m) -> eq nat n m := axiom;
|
axiom suc_inj : forall (n m : nat), eq nat (suc n) (suc m) -> eq nat n m;
|
||||||
|
|
||||||
-- axiom 8: No successor of any natural number is zero.
|
-- axiom 8: No successor of any natural number is zero.
|
||||||
suc_nonzero : forall (n : nat), not (eq nat (suc n) zero) := axiom;
|
axiom suc_nonzero : forall (n : nat), not (eq nat (suc n) zero);
|
||||||
|
|
||||||
-- axiom 9: Induction! For any proposition P on natural numbers, if P(0) holds,
|
-- axiom 9: Induction! For any proposition P on natural numbers, if P(0) holds,
|
||||||
-- and if for every natural number n, P(n) ⇒ P(S n), then P holds for all n.
|
-- and if for every natural number n, P(n) ⇒ P(S n), then P holds for all n.
|
||||||
nat_ind : forall (P : nat -> *), P zero -> (forall (n : nat), P n -> P (suc n))
|
axiom nat_ind : forall (P : nat -> *), P zero -> (forall (n : nat), P n -> P (suc n))
|
||||||
-> forall (n : nat), P n := axiom;
|
-> forall (n : nat), P n;
|
||||||
|
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
|
@ -77,27 +77,27 @@ nat_ind : forall (P : nat -> *), P zero -> (forall (n : nat), P n -> P (suc n))
|
||||||
-- long and complicated really quickly.
|
-- long and complicated really quickly.
|
||||||
|
|
||||||
-- Some abbreviations for common numbers.
|
-- Some abbreviations for common numbers.
|
||||||
one : nat := suc zero;
|
def one : nat := suc zero;
|
||||||
two : nat := suc one;
|
def two : nat := suc one;
|
||||||
three : nat := suc two;
|
def three : nat := suc two;
|
||||||
four : nat := suc three;
|
def four : nat := suc three;
|
||||||
five : nat := suc four;
|
def five : nat := suc four;
|
||||||
|
|
||||||
-- First, the predecessor of n is m if n = suc m.
|
-- First, the predecessor of n is m if n = suc m.
|
||||||
pred (n m : nat) : * := eq nat n (suc m);
|
def pred (n m : nat) : * := eq nat n (suc m);
|
||||||
|
|
||||||
-- Our claim is a disjunction, whose first option is that n = 0.
|
-- Our claim is a disjunction, whose first option is that n = 0.
|
||||||
szc_l (n : nat) := eq nat n zero;
|
def szc_l (n : nat) := eq nat n zero;
|
||||||
|
|
||||||
-- The second option is that n has a predecessor.
|
-- The second option is that n has a predecessor.
|
||||||
szc_r (n : nat) := exists nat (pred n);
|
def szc_r (n : nat) := exists nat (pred n);
|
||||||
|
|
||||||
-- So the claim we are trying to prove is that either one of the above options
|
-- So the claim we are trying to prove is that either one of the above options
|
||||||
-- holds for every n.
|
-- holds for every n.
|
||||||
szc (n : nat) := or (szc_l n) (szc_r n);
|
def szc (n : nat) := or (szc_l n) (szc_r n);
|
||||||
|
|
||||||
-- And here's our proof!
|
-- And here's our proof!
|
||||||
suc_or_zero : forall (n : nat), szc n :=
|
def suc_or_zero : forall (n : nat), szc n :=
|
||||||
-- We will prove this by induction.
|
-- We will prove this by induction.
|
||||||
nat_ind szc
|
nat_ind szc
|
||||||
-- For the base case, the first option holds, i.e. 0 = 0
|
-- For the base case, the first option holds, i.e. 0 = 0
|
||||||
|
|
@ -157,30 +157,30 @@ suc_or_zero : forall (n : nat), szc n :=
|
||||||
|
|
||||||
-- {{{ Defining R
|
-- {{{ Defining R
|
||||||
-- Here is condition 1 formally expressed in perga.
|
-- Here is condition 1 formally expressed in perga.
|
||||||
cond1 (A : *) (z : A) (fS : nat -> A -> A) (Q : nat -> A -> *) :=
|
def cond1 (A : *) (z : A) (fS : nat -> A -> A) (Q : nat -> A -> *) :=
|
||||||
Q zero z;
|
Q zero z;
|
||||||
|
|
||||||
-- Likewise for condition 2.
|
-- Likewise for condition 2.
|
||||||
cond2 (A : *) (z : A) (fS : nat -> A -> A) (Q : nat -> A -> *) :=
|
def cond2 (A : *) (z : A) (fS : nat -> A -> A) (Q : nat -> A -> *) :=
|
||||||
forall (n : nat) (y : A), Q n y -> Q (suc n) (fS n y);
|
forall (n : nat) (y : A), Q n y -> Q (suc n) (fS n y);
|
||||||
|
|
||||||
-- From here we can define R.
|
-- From here we can define R.
|
||||||
rec_rel (A : *) (z : A) (fS : nat -> A -> A) (x : nat) (y : A) :=
|
def rec_rel (A : *) (z : A) (fS : nat -> A -> A) (x : nat) (y : A) :=
|
||||||
forall (Q : nat -> A -> *), cond1 A z fS Q -> cond2 A z fS Q -> Q x y;
|
forall (Q : nat -> A -> *), cond1 A z fS Q -> cond2 A z fS Q -> Q x y;
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
-- {{{ R is total
|
-- {{{ R is total
|
||||||
total (A B : *) (R : A -> B -> *) := forall (a : A), exists B (R a);
|
def total (A B : *) (R : A -> B -> *) := forall (a : A), exists B (R a);
|
||||||
|
|
||||||
rec_rel_cond1 (A : *) (z : A) (fS : nat -> A -> A) : cond1 A z fS (rec_rel A z fS) :=
|
def rec_rel_cond1 (A : *) (z : A) (fS : nat -> A -> A) : cond1 A z fS (rec_rel A z fS) :=
|
||||||
fun (Q : nat -> A -> *) (h1 : cond1 A z fS Q) (h2 : cond2 A z fS Q) => h1;
|
fun (Q : nat -> A -> *) (h1 : cond1 A z fS Q) (h2 : cond2 A z fS Q) => h1;
|
||||||
|
|
||||||
rec_rel_cond2 (A : *) (z : A) (fS : nat -> A -> A) : cond2 A z fS (rec_rel A z fS) :=
|
def rec_rel_cond2 (A : *) (z : A) (fS : nat -> A -> A) : cond2 A z fS (rec_rel A z fS) :=
|
||||||
fun (n : nat) (y : A) (h : rec_rel A z fS n y)
|
fun (n : nat) (y : A) (h : rec_rel A z fS n y)
|
||||||
(Q : nat -> A -> *) (h1 : cond1 A z fS Q) (h2 : cond2 A z fS Q) =>
|
(Q : nat -> A -> *) (h1 : cond1 A z fS Q) (h2 : cond2 A z fS Q) =>
|
||||||
h2 n y (h Q h1 h2);
|
h2 n y (h Q h1 h2);
|
||||||
|
|
||||||
rec_rel_total (A : *) (z : A) (fS : nat -> A -> A) : total nat A (rec_rel A z fS) :=
|
def rec_rel_total (A : *) (z : A) (fS : nat -> A -> A) : total nat A (rec_rel A z fS) :=
|
||||||
let (R := rec_rel A z fS)
|
let (R := rec_rel A z fS)
|
||||||
(P (x : nat) := exists A (R x))
|
(P (x : nat) := exists A (R x))
|
||||||
(c1 := cond1 A z fS)
|
(c1 := cond1 A z fS)
|
||||||
|
|
@ -196,27 +196,27 @@ rec_rel_total (A : *) (z : A) (fS : nat -> A -> A) : total nat A (rec_rel A z fS
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
-- {{{ Defining R2
|
-- {{{ Defining R2
|
||||||
alt_cond1 (A : *) (z : A) (x : nat) (y : A) :=
|
def alt_cond1 (A : *) (z : A) (x : nat) (y : A) :=
|
||||||
and (eq nat x zero) (eq A y z);
|
and (eq nat x zero) (eq A y z);
|
||||||
|
|
||||||
cond_y2 (A : *) (z : A) (fS : nat -> A -> A) (x : nat) (y : A)
|
def cond_y2 (A : *) (z : A) (fS : nat -> A -> A) (x : nat) (y : A)
|
||||||
(x2 : nat) (y2 : A) :=
|
(x2 : nat) (y2 : A) :=
|
||||||
and (eq A y (fS x2 y2)) (rec_rel A z fS x2 y2);
|
and (eq A y (fS x2 y2)) (rec_rel A z fS x2 y2);
|
||||||
|
|
||||||
cond_x2 (A : *) (z : A) (fS : nat -> A -> A) (x : nat) (y : A) (x2 : nat) :=
|
def cond_x2 (A : *) (z : A) (fS : nat -> A -> A) (x : nat) (y : A) (x2 : nat) :=
|
||||||
and (pred x x2) (exists A (cond_y2 A z fS x y x2));
|
and (pred x x2) (exists A (cond_y2 A z fS x y x2));
|
||||||
|
|
||||||
alt_cond2 (A : *) (z : A) (fS : nat -> A -> A) (x : nat) (y : A) :=
|
def alt_cond2 (A : *) (z : A) (fS : nat -> A -> A) (x : nat) (y : A) :=
|
||||||
exists nat (cond_x2 A z fS x y);
|
exists nat (cond_x2 A z fS x y);
|
||||||
|
|
||||||
rec_rel_alt (A : *) (z : A) (fS : nat -> A -> A) (x : nat) (y : A) :=
|
def rec_rel_alt (A : *) (z : A) (fS : nat -> A -> A) (x : nat) (y : A) :=
|
||||||
or (alt_cond1 A z x y) (alt_cond2 A z fS x y);
|
or (alt_cond1 A z x y) (alt_cond2 A z fS x y);
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
-- {{{ R = R2
|
-- {{{ R = R2
|
||||||
|
|
||||||
-- {{{ R2 ⊆ R
|
-- {{{ R2 ⊆ R
|
||||||
R2_sub_R (A : *) (z : A) (fS : nat -> A -> A) (x : nat) (y : A) :
|
def R2_sub_R (A : *) (z : A) (fS : nat -> A -> A) (x : nat) (y : A) :
|
||||||
rec_rel_alt A z fS x y -> rec_rel A z fS x y :=
|
rec_rel_alt A z fS x y -> rec_rel A z fS x y :=
|
||||||
let (R := rec_rel A z fS)
|
let (R := rec_rel A z fS)
|
||||||
(R2 := rec_rel_alt A z fS)
|
(R2 := rec_rel_alt A z fS)
|
||||||
|
|
@ -257,13 +257,13 @@ R2_sub_R (A : *) (z : A) (fS : nat -> A -> A) (x : nat) (y : A) :
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
-- {{{ R ⊆ R2
|
-- {{{ R ⊆ R2
|
||||||
R2_cond1 (A : *) (z : A) (fS : nat -> A -> A) : cond1 A z fS (rec_rel_alt A z fS) :=
|
def R2_cond1 (A : *) (z : A) (fS : nat -> A -> A) : cond1 A z fS (rec_rel_alt A z fS) :=
|
||||||
or_intro_l (alt_cond1 A z zero z) (alt_cond2 A z fS zero z)
|
or_intro_l (alt_cond1 A z zero z) (alt_cond2 A z fS zero z)
|
||||||
(and_intro (eq nat zero zero) (eq A z z)
|
(and_intro (eq nat zero zero) (eq A z z)
|
||||||
(eq_refl nat zero)
|
(eq_refl nat zero)
|
||||||
(eq_refl A z));
|
(eq_refl A z));
|
||||||
|
|
||||||
R2_cond2 (A : *) (z : A) (fS : nat -> A -> A) : cond2 A z fS (rec_rel_alt A z fS) :=
|
def R2_cond2 (A : *) (z : A) (fS : nat -> A -> A) : cond2 A z fS (rec_rel_alt A z fS) :=
|
||||||
let (R := rec_rel A z fS)
|
let (R := rec_rel A z fS)
|
||||||
(R2 := rec_rel_alt A z fS)
|
(R2 := rec_rel_alt A z fS)
|
||||||
in
|
in
|
||||||
|
|
@ -284,7 +284,7 @@ R2_cond2 (A : *) (z : A) (fS : nat -> A -> A) : cond2 A z fS (rec_rel_alt A z fS
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
|
|
||||||
R_sub_R2 (A : *) (z : A) (fS : nat -> A -> A) (x : nat) (y : A) :
|
def R_sub_R2 (A : *) (z : A) (fS : nat -> A -> A) (x : nat) (y : A) :
|
||||||
rec_rel A z fS x y -> rec_rel_alt A z fS x y :=
|
rec_rel A z fS x y -> rec_rel_alt A z fS x y :=
|
||||||
let (R := rec_rel A z fS)
|
let (R := rec_rel A z fS)
|
||||||
(R2 := rec_rel_alt A z fS)
|
(R2 := rec_rel_alt A z fS)
|
||||||
|
|
@ -298,12 +298,12 @@ R_sub_R2 (A : *) (z : A) (fS : nat -> A -> A) (x : nat) (y : A) :
|
||||||
|
|
||||||
-- {{{ R2 (hence R) is functional
|
-- {{{ R2 (hence R) is functional
|
||||||
|
|
||||||
fl_in (A B : *) (R : A -> B -> *) (x : A) := forall (y1 y2 : B),
|
def fl_in (A B : *) (R : A -> B -> *) (x : A) := forall (y1 y2 : B),
|
||||||
R x y1 -> R x y2 -> eq B y1 y2;
|
R x y1 -> R x y2 -> eq B y1 y2;
|
||||||
|
|
||||||
fl (A B : *) (R : A -> B -> *) := forall (x : A), fl_in A B R x;
|
def fl (A B : *) (R : A -> B -> *) := forall (x : A), fl_in A B R x;
|
||||||
|
|
||||||
R2_zero (A : *) (z : A) (fS : nat -> A -> A) (y : A) :
|
def R2_zero (A : *) (z : A) (fS : nat -> A -> A) (y : A) :
|
||||||
rec_rel_alt A z fS zero y -> eq A y z :=
|
rec_rel_alt A z fS zero y -> eq A y z :=
|
||||||
let (R2 := rec_rel_alt A z fS)
|
let (R2 := rec_rel_alt A z fS)
|
||||||
(ac1 := alt_cond1 A z zero y)
|
(ac1 := alt_cond1 A z zero y)
|
||||||
|
|
@ -321,7 +321,7 @@ R2_zero (A : *) (z : A) (fS : nat -> A -> A) (y : A) :
|
||||||
(eq A y z)))
|
(eq A y z)))
|
||||||
end;
|
end;
|
||||||
|
|
||||||
R2_suc (A : *) (z : A) (fS : nat -> A -> A) (x2 : nat) (y : A) :
|
def R2_suc (A : *) (z : A) (fS : nat -> A -> A) (x2 : nat) (y : A) :
|
||||||
rec_rel_alt A z fS (suc x2) y -> exists A (cond_y2 A z fS (suc x2) y x2) :=
|
rec_rel_alt A z fS (suc x2) y -> exists A (cond_y2 A z fS (suc x2) y x2) :=
|
||||||
let (R2 := rec_rel_alt A z fS)
|
let (R2 := rec_rel_alt A z fS)
|
||||||
(x := suc x2)
|
(x := suc x2)
|
||||||
|
|
@ -347,7 +347,7 @@ R2_suc (A : *) (z : A) (fS : nat -> A -> A) (x2 : nat) (y : A) :
|
||||||
end))
|
end))
|
||||||
end;
|
end;
|
||||||
|
|
||||||
R2_functional (A : *) (z : A) (fS : nat -> A -> A) : fl nat A (rec_rel_alt A z fS) :=
|
def R2_functional (A : *) (z : A) (fS : nat -> A -> A) : fl nat A (rec_rel_alt A z fS) :=
|
||||||
let (R := rec_rel A z fS)
|
let (R := rec_rel A z fS)
|
||||||
(R2 := rec_rel_alt A z fS)
|
(R2 := rec_rel_alt A z fS)
|
||||||
(f_in := fl_in nat A R2)
|
(f_in := fl_in nat A R2)
|
||||||
|
|
@ -385,7 +385,7 @@ R2_functional (A : *) (z : A) (fS : nat -> A -> A) : fl nat A (rec_rel_alt A z f
|
||||||
|
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
rec_def (A : *) (z : A) (fS : nat -> A -> A) (x : nat) : A :=
|
def rec_def (A : *) (z : A) (fS : nat -> A -> A) (x : nat) : A :=
|
||||||
exists_elim A A (rec_rel A z fS x) (rec_rel_total A z fS x)
|
exists_elim A A (rec_rel A z fS x) (rec_rel_total A z fS x)
|
||||||
(fun (y : A) (_ : rec_rel A z fS x y) => y);
|
(fun (y : A) (_ : rec_rel A z fS x y) => y);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue