Commit 8b720c66 authored by Raphael Cauderlier's avatar Raphael Cauderlier

type -> sort

parent 0d0c865f
#NAME NUM343_1. #NAME NUM343_1.
def type := fol.type. def sort := fol.sort.
def term := fol.term. def term := fol.term.
def prop := fol.prop. def prop := fol.prop.
def proof := fol.proof. def proof := fol.proof.
...@@ -15,19 +15,19 @@ def predicate := fol.predicate. ...@@ -15,19 +15,19 @@ def predicate := fol.predicate.
def function := fol.function. def function := fol.function.
def pred_apply := fol.pred_apply. def pred_apply := fol.pred_apply.
def fun_apply := fol.fun_apply. def fun_apply := fol.fun_apply.
def read_types := fol.read_types. def read_sorts := fol.read_sorts.
def nil_type := fol.nil_type. def nil_sort := fol.nil_sort.
def 0 := nat.O. def 0 := nat.O.
def 1 := nat.S 0. def 1 := nat.S 0.
def 2 := nat.S 1. def 2 := nat.S 1.
(; Signature ;) (; Signature ;)
A : type. A : sort.
LEQ : predicate. LEQ : predicate.
[] fol.pred_arity LEQ --> read_types 2 A A. [] fol.pred_arity LEQ --> read_sorts 2 A A.
N : function. N : function.
[] fol.fun_arity N --> nil_type. [] fol.fun_arity N --> nil_sort.
[] fol.fun_codomain N --> A. [] fol.fun_codomain N --> A.
def leq : term A -> term A -> prop := pred_apply LEQ. def leq : term A -> term A -> prop := pred_apply LEQ.
......
...@@ -7,18 +7,18 @@ ...@@ -7,18 +7,18 @@
(setq-local dedukti-compile-options '("-nc" "-e" "-nl" "-I" "../fol" "-I" "../meta")) (setq-local dedukti-compile-options '("-nc" "-e" "-nl" "-I" "../fol" "-I" "../meta"))
;) ;)
BAR : fol.type. BAR : fol.sort.
(; We have to assume that the bar is not empty, that is we have a term (; We have to assume that the bar is not empty, that is we have a term
of type BAR. Let's call it Joe. ;) of sort BAR. Let's call it Joe. ;)
JOE : fol.function. JOE : fol.function.
[] fol.fun_arity JOE --> fol.nil_type. [] fol.fun_arity JOE --> fol.nil_sort.
[] fol.fun_codomain JOE --> BAR. [] fol.fun_codomain JOE --> BAR.
def Joe : fol.term BAR := fol.fun_apply JOE. def Joe : fol.term BAR := fol.fun_apply JOE.
(; The "drink" predicate. ;) (; The "drink" predicate. ;)
DRINK : fol.predicate. DRINK : fol.predicate.
[] fol.pred_arity DRINK --> fol.read_types (nat.S nat.O) BAR. [] fol.pred_arity DRINK --> fol.read_sorts (nat.S nat.O) BAR.
def drink (x : fol.term BAR) : fol.prop := fol.pred_apply DRINK x. def drink (x : fol.term BAR) : fol.prop := fol.pred_apply DRINK x.
def drinker_statement : fol.prop := def drinker_statement : fol.prop :=
...@@ -50,7 +50,7 @@ def drinker_paradox : fol.proof drinker_statement := ...@@ -50,7 +50,7 @@ def drinker_paradox : fol.proof drinker_statement :=
(cert.with_assumption (E => e => (cert.with_assumption (E => e =>
cert.destruct_ex BAR ndrink (cert.exact E e) cert.destruct_ex BAR ndrink (cert.exact E e)
(; ¬∀, ∃¬, John, ¬drink John ⊢ ∃x. drink x → ∀ ;) (; ¬∀, ∃¬, John, ¬drink John ⊢ ∃x. drink x → ∀ ;)
(cert.with_variable (B : fol.type => John : fol.term B => (cert.with_variable (B : fol.sort => John : fol.term B =>
cert.exists B John cert.exists B John
(; ¬∀, ∃¬, John, ¬drink John ⊢ drink John → ∀ ;) (; ¬∀, ∃¬, John, ¬drink John ⊢ drink John → ∀ ;)
(cert.intro cert.absurd)))))))). (cert.intro cert.absurd)))))))).
#NAME resolution_examples. #NAME resolution_examples.
def type := fol.type. def sort := fol.sort.
def term := fol.term. def term := fol.term.
def prop := fol.prop. def prop := fol.prop.
def proof := fol.proof. def proof := fol.proof.
...@@ -15,21 +15,21 @@ def predicate := fol.predicate. ...@@ -15,21 +15,21 @@ def predicate := fol.predicate.
def function := fol.function. def function := fol.function.
def pred_apply := fol.pred_apply. def pred_apply := fol.pred_apply.
def fun_apply := fol.fun_apply. def fun_apply := fol.fun_apply.
def read_types := fol.read_types. def read_sorts := fol.read_sorts.
def nil_type := fol.nil_type. def nil_sort := fol.nil_sort.
def 0 := nat.O. def 0 := nat.O.
def 1 := nat.S 0. def 1 := nat.S 0.
(; Signature ;) (; Signature ;)
A : type. A : sort.
P : predicate. P : predicate.
[] fol.pred_arity P --> read_types 1 A. [] fol.pred_arity P --> read_sorts 1 A.
O : function. O : function.
[] fol.fun_arity O --> nil_type. [] fol.fun_arity O --> nil_sort.
[] fol.fun_codomain O --> A. [] fol.fun_codomain O --> A.
S : function. S : function.
[] fol.fun_arity S --> read_types 1 A. [] fol.fun_arity S --> read_sorts 1 A.
[] fol.fun_codomain S --> A. [] fol.fun_codomain S --> A.
def p : term A -> prop := pred_apply P. def p : term A -> prop := pred_apply P.
......
...@@ -13,4 +13,4 @@ cons_clause : litteral -> clause -> clause. ...@@ -13,4 +13,4 @@ cons_clause : litteral -> clause -> clause.
qclause : Type. qclause : Type.
qc_base : clause -> qclause. qc_base : clause -> qclause.
qc_all : A : fol.type -> (fol.term A -> qclause) -> qclause. qc_all : A : fol.sort -> (fol.term A -> qclause) -> qclause.
#NAME eq. #NAME eq.
def type := fol.type. def sort := fol.sort.
def types := fol.types. def sorts := fol.sorts.
def term := fol.term. def term := fol.term.
def terms := fol.terms. def terms := fol.terms.
def nil_term := fol.nil_term. def nil_term := fol.nil_term.
def cons_term := fol.cons_term. def cons_term := fol.cons_term.
def read_types := fol.read_types. def read_sorts := fol.read_sorts.
def prop := fol.prop. def prop := fol.prop.
def imp := fol.imp. def imp := fol.imp.
...@@ -27,21 +27,21 @@ def O := nat.O. ...@@ -27,21 +27,21 @@ def O := nat.O.
def S := nat.S. def S := nat.S.
(; Equality is a family of binary predicate symbols. ;) (; Equality is a family of binary predicate symbols. ;)
Eq : type -> predicate. Eq : sort -> predicate.
[A] fol.pred_arity (Eq A) --> read_types (S (S O)) A A. [A] fol.pred_arity (Eq A) --> read_sorts (S (S O)) A A.
def eq (A : type) : term A -> term A -> prop := pred_apply (Eq A). def eq (A : sort) : term A -> term A -> prop := pred_apply (Eq A).
[A,x,y] [A,x,y]
fol.proof (fol.apply_pred (Eq A) fol.proof (fol.apply_pred (Eq A)
(fol.cons_term _ x _ (fol.cons_term _ y _ fol.nil_term))) --> (fol.cons_term _ x _ (fol.cons_term _ y _ fol.nil_term))) -->
p : (term A -> prop) -> proof (p x) -> proof (p y). p : (term A -> prop) -> proof (p x) -> proof (p y).
def eq_refl (A : type) : proof (all A (x => eq A x x)) := def eq_refl (A : sort) : proof (all A (x => eq A x x)) :=
fol.all_intro A (x => eq A x x) (x => p => H => H). fol.all_intro A (x => eq A x x) (x => p => H => H).
def eq_congr (A : type) (x : term A) (y : term A) (H : proof (eq A x y)) : c : (term A -> prop) -> proof (c x) -> proof (c y) := H. def eq_congr (A : sort) (x : term A) (y : term A) (H : proof (eq A x y)) : c : (term A -> prop) -> proof (c x) -> proof (c y) := H.
def eq_symm (A : type) : def eq_symm (A : sort) :
proof (all A (x : term A => proof (all A (x : term A =>
all A (y : term A => all A (y : term A =>
imp (eq A y x) (eq A x y)))) := imp (eq A y x) (eq A x y)))) :=
...@@ -50,7 +50,7 @@ def eq_symm (A : type) : ...@@ -50,7 +50,7 @@ def eq_symm (A : type) :
(y => fol.imp_intro (eq A y x) (eq A x y) (y => fol.imp_intro (eq A y x) (eq A x y)
(Hyx => eq_congr A y x Hyx (z => eq A z y) (fol.all_elim A (x => eq A x x) (eq_refl A) y)))). (Hyx => eq_congr A y x Hyx (z => eq A z y) (fol.all_elim A (x => eq A x x) (eq_refl A) y)))).
def eq_trans (A : type) : def eq_trans (A : sort) :
proof (all A (x : term A => proof (all A (x : term A =>
all A (y : term A => all A (y : term A =>
all A (z : term A => all A (z : term A =>
...@@ -64,7 +64,7 @@ def eq_trans (A : type) : ...@@ -64,7 +64,7 @@ def eq_trans (A : type) :
(Hxy => fol.imp_intro (eq A y z) (eq A x z) (Hxy => fol.imp_intro (eq A y z) (eq A x z)
(Hyz => eq_congr A y z Hyz (t => eq A x t) Hxy))))). (Hyz => eq_congr A y z Hyz (t => eq A x t) Hxy))))).
def eq_p_equal (A : type) (p : term A -> prop) : def eq_p_equal (A : sort) (p : term A -> prop) :
proof (all A (x : term A => proof (all A (x : term A =>
all A (y : term A => all A (y : term A =>
imp (eq A x y) (imp (p x) (p y))))) := imp (eq A x y) (imp (p x) (p y))))) :=
...@@ -74,21 +74,21 @@ def eq_p_equal (A : type) (p : term A -> prop) : ...@@ -74,21 +74,21 @@ def eq_p_equal (A : type) (p : term A -> prop) :
(Hxy => fol.imp_intro (p x) (p y) (Hxy => fol.imp_intro (p x) (p y)
(Hpx => eq_congr A x y Hxy p Hpx)))). (Hpx => eq_congr A x y Hxy p Hpx)))).
eq_f_equal : A : type -> B : type -> f : (term A -> term B) -> eq_f_equal : A : sort -> B : sort -> f : (term A -> term B) ->
proof (all A (x : term A => proof (all A (x : term A =>
all A (y : term A => all A (y : term A =>
imp (eq A x y) (eq B (f x) (f y))))). imp (eq A x y) (eq B (f x) (f y))))).
def pred_imp : L : types -> (terms L -> prop) -> (terms L -> prop) -> prop. def pred_imp : L : sorts -> (terms L -> prop) -> (terms L -> prop) -> prop.
[p,q] pred_imp fol.nil_type p q --> imp (p nil_term) (q nil_term) [p,q] pred_imp fol.nil_sort p q --> imp (p nil_term) (q nil_term)
[A,L,p,q] pred_imp (fol.cons_type A L) p q --> [A,L,p,q] pred_imp (fol.cons_sort A L) p q -->
all A (x : term A => all A (x : term A =>
all A (y : term A => all A (y : term A =>
imp (eq A x y) (pred_imp L (l : terms L => p (cons_term A x L l)) (l : terms L => q (cons_term A y L l))))). imp (eq A x y) (pred_imp L (l : terms L => p (cons_term A x L l)) (l : terms L => q (cons_term A y L l))))).
def eq_pred_imp : L : types -> p : (terms L -> prop) -> proof (pred_imp L p p). def eq_pred_imp : L : sorts -> p : (terms L -> prop) -> proof (pred_imp L p p).
[p] eq_pred_imp fol.nil_type p --> fol.imp_intro (p nil_term) (p nil_term) (Hp => Hp) [p] eq_pred_imp fol.nil_sort p --> fol.imp_intro (p nil_term) (p nil_term) (Hp => Hp)
[A,L,p] eq_pred_imp (fol.cons_type A L) p --> [A,L,p] eq_pred_imp (fol.cons_sort A L) p -->
fol.all_intro A (x => all A (y => imp (eq A x y) (pred_imp L (l => p (cons_term A x L l)) (l => p (cons_term A y L l))))) fol.all_intro A (x => all A (y => imp (eq A x y) (pred_imp L (l => p (cons_term A x L l)) (l => p (cons_term A y L l)))))
(x => (x =>
fol.all_intro A (y => imp (eq A x y) (pred_imp L (l => p (cons_term A x L l)) (l => p (cons_term A y L l)))) fol.all_intro A (y => imp (eq A x y) (pred_imp L (l => p (cons_term A x L l)) (l => p (cons_term A y L l))))
...@@ -100,16 +100,16 @@ def eq_pred_imp : L : types -> p : (terms L -> prop) -> proof (pred_imp L p p). ...@@ -100,16 +100,16 @@ def eq_pred_imp : L : types -> p : (terms L -> prop) -> proof (pred_imp L p p).
thm eq_pred_equal (p : predicate) : proof (pred_imp (pred_arity p) (apply_pred p) (apply_pred p)) thm eq_pred_equal (p : predicate) : proof (pred_imp (pred_arity p) (apply_pred p) (apply_pred p))
:= eq_pred_imp (pred_arity p) (apply_pred p). := eq_pred_imp (pred_arity p) (apply_pred p).
def fun_eq : L : types -> B : type -> (terms L -> term B) -> (terms L -> term B) -> prop. def fun_eq : L : sorts -> B : sort -> (terms L -> term B) -> (terms L -> term B) -> prop.
[B,b,b'] fun_eq fol.nil_type B b b' --> eq B (b nil_term) (b' nil_term) [B,b,b'] fun_eq fol.nil_sort B b b' --> eq B (b nil_term) (b' nil_term)
[A,L,B,f,f'] fun_eq (fol.cons_type A L) B f f' --> [A,L,B,f,f'] fun_eq (fol.cons_sort A L) B f f' -->
all A (x : term A => all A (x : term A =>
all A (y : term A => all A (y : term A =>
imp (eq A x y) (fun_eq L B (l : terms L => f (cons_term A x L l)) (l : terms L => f' (cons_term A y L l))))). imp (eq A x y) (fun_eq L B (l : terms L => f (cons_term A x L l)) (l : terms L => f' (cons_term A y L l))))).
def eq_fun_eq : L : types -> B : type -> f : (terms L -> term B) -> proof (fun_eq L B f f). def eq_fun_eq : L : sorts -> B : sort -> f : (terms L -> term B) -> proof (fun_eq L B f f).
[B,b] eq_fun_eq fol.nil_type B b --> fol.all_elim B (x => eq B x x) (eq_refl B) (b nil_term) [B,b] eq_fun_eq fol.nil_sort B b --> fol.all_elim B (x => eq B x x) (eq_refl B) (b nil_term)
[A,L,B,f,f'] eq_fun_eq (fol.cons_type A L) B f --> [A,L,B,f,f'] eq_fun_eq (fol.cons_sort A L) B f -->
fol.all_intro A (x => all A (y => imp (eq A x y) (fun_eq L B (l : terms L => f (cons_term A x L l)) (l : terms L => f (cons_term A y L l))))) fol.all_intro A (x => all A (y => imp (eq A x y) (fun_eq L B (l : terms L => f (cons_term A x L l)) (l : terms L => f (cons_term A y L l)))))
(x => (x =>
fol.all_intro A (y => imp (eq A x y) (fun_eq L B (l : terms L => f (cons_term A x L l)) (l : terms L => f (cons_term A y L l)))) fol.all_intro A (y => imp (eq A x y) (fun_eq L B (l : terms L => f (cons_term A x L l)) (l : terms L => f (cons_term A y L l))))
......
This diff is collapsed.
#NAME inhabited_types.
def default_value : A : fol.type -> fol.term A.
...@@ -5,7 +5,7 @@ https://en.wikipedia.org/wiki/Presburger_arithmetic ;) ...@@ -5,7 +5,7 @@ https://en.wikipedia.org/wiki/Presburger_arithmetic ;)
(; There is just one sort representing natural numbers ;) (; There is just one sort representing natural numbers ;)
Nat : fol.type. Nat : fol.sort.
(; There is just one predicate symbol for equality ;) (; There is just one predicate symbol for equality ;)
EQ : fol.predicate. EQ : fol.predicate.
...@@ -21,10 +21,10 @@ ONE : fol.function. ...@@ -21,10 +21,10 @@ ONE : fol.function.
ADD : fol.function. ADD : fol.function.
(; Arities ;) (; Arities ;)
[] fol.pred_arity EQ --> fol.read_types (nat.S (nat.S nat.O)) Nat Nat. [] fol.pred_arity EQ --> fol.read_sorts (nat.S (nat.S nat.O)) Nat Nat.
[] fol.fun_arity ZERO --> fol.nil_type. [] fol.fun_arity ZERO --> fol.nil_sort.
[] fol.fun_arity ONE --> fol.nil_type. [] fol.fun_arity ONE --> fol.nil_sort.
[] fol.fun_arity ADD --> fol.read_types (nat.S (nat.S nat.O)) Nat Nat. [] fol.fun_arity ADD --> fol.read_sorts (nat.S (nat.S nat.O)) Nat Nat.
[] fol.fun_codomain ZERO --> Nat. [] fol.fun_codomain ZERO --> Nat.
[] fol.fun_codomain ONE --> Nat. [] fol.fun_codomain ONE --> Nat.
[] fol.fun_codomain ADD --> Nat. [] fol.fun_codomain ADD --> Nat.
......
This diff is collapsed.
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
;) ;)
def type := fol.type. def sort := fol.sort.
def term := fol.term. def term := fol.term.
def prop := fol.prop. def prop := fol.prop.
def proof := fol.proof. def proof := fol.proof.
...@@ -17,7 +17,7 @@ def imp := fol.imp. ...@@ -17,7 +17,7 @@ def imp := fol.imp.
context : Type. context : Type.
nil_ctx : context. nil_ctx : context.
cons_ctx_var : A : type -> term A -> context -> context. cons_ctx_var : A : sort -> term A -> context -> context.
cons_ctx_proof : A : prop -> proof A -> context -> context. cons_ctx_proof : A : prop -> proof A -> context -> context.
certificate : Type. certificate : Type.
...@@ -85,7 +85,7 @@ clear : prop -> certificate -> certificate. ...@@ -85,7 +85,7 @@ clear : prop -> certificate -> certificate.
[A,G,B,c] run A G (clear B c) --> run A (ctx_remove B G) c. [A,G,B,c] run A G (clear B c) --> run A (ctx_remove B G) c.
no_successful_variable : fol.prop -> context -> tac.exc. no_successful_variable : fol.prop -> context -> tac.exc.
def try_all_variables : (A : type -> term A -> certificate) -> context -> certificate. def try_all_variables : (A : sort -> term A -> certificate) -> context -> certificate.
[] try_all_variables _ nil_ctx --> [] try_all_variables _ nil_ctx -->
with_goal (A => with_goal (A =>
with_context (G => with_context (G =>
...@@ -101,7 +101,7 @@ def try_all_variables : (A : type -> term A -> certificate) -> context -> certif ...@@ -101,7 +101,7 @@ def try_all_variables : (A : type -> term A -> certificate) -> context -> certif
(; with_variable (A => a => c) proves G |- B if c proves G |- B for (; with_variable (A => a => c) proves G |- B if c proves G |- B for
any variable (a : A) in G;) any variable (a : A) in G;)
def with_variable (f : A : type -> term A -> certificate) : certificate def with_variable (f : A : sort -> term A -> certificate) : certificate
:= :=
with_context (G => try_all_variables f G). with_context (G => try_all_variables f G).
...@@ -166,7 +166,7 @@ def read_props : m : nat.Nat -> n : nat.Nat -> k : nat.Nat -> As : props m -> re ...@@ -166,7 +166,7 @@ def read_props : m : nat.Nat -> n : nat.Nat -> k : nat.Nat -> As : props m -> re
def refinen (n : nat.Nat) := read_props nat.O n n nil_prop. def refinen (n : nat.Nat) := read_props nat.O n n nil_prop.
(; fix_term A f a proves G |- B if f (fix_term A f) a proves G |- B ;) (; fix_term A f a proves G |- B if f (fix_term A f) a proves G |- B ;)
def fix_term : A : type -> ((term A -> certificate) -> term A -> certificate) -> term A -> certificate. def fix_term : A : sort -> ((term A -> certificate) -> term A -> certificate) -> term A -> certificate.
[A,F,a] fix_term A F a --> F (fix_term A F) a. [A,F,a] fix_term A F a --> F (fix_term A F) a.
def fix_prop : ((prop -> certificate) -> prop -> certificate) -> prop -> certificate. def fix_prop : ((prop -> certificate) -> prop -> certificate) -> prop -> certificate.
...@@ -212,8 +212,8 @@ def match_prop : prop -> ...@@ -212,8 +212,8 @@ def match_prop : prop ->
(prop -> prop -> certificate) -> (; and ;) (prop -> prop -> certificate) -> (; and ;)
(prop -> prop -> certificate) -> (; or ;) (prop -> prop -> certificate) -> (; or ;)
(prop -> prop -> certificate) -> (; imp ;) (prop -> prop -> certificate) -> (; imp ;)
(A : type -> (term A -> prop) -> certificate) -> (; all ;) (A : sort -> (term A -> prop) -> certificate) -> (; all ;)
(A : type -> (term A -> prop) -> certificate) -> (; ex ;) (A : sort -> (term A -> prop) -> certificate) -> (; ex ;)
(p : fol.predicate -> (p : fol.predicate ->
fol.terms (fol.pred_arity p) -> fol.terms (fol.pred_arity p) ->
certificate) -> certificate) ->
...@@ -267,7 +267,7 @@ def match_imp (A : prop) (c1 : prop -> prop -> certificate) (c2 : certificate) : ...@@ -267,7 +267,7 @@ def match_imp (A : prop) (c1 : prop -> prop -> certificate) (c2 : certificate) :
(__ => __ => c2) (__ => __ => c2)
(__ => __ => c2). (__ => __ => c2).
def match_all (A : prop) (c1 : A : type -> (term A -> prop) -> certificate) (c2 : certificate) : certificate := def match_all (A : prop) (c1 : A : sort -> (term A -> prop) -> certificate) (c2 : certificate) : certificate :=
match_prop A match_prop A
c2 c2
(__ => __ => c2) (__ => __ => c2)
...@@ -277,7 +277,7 @@ def match_all (A : prop) (c1 : A : type -> (term A -> prop) -> certificate) (c2 ...@@ -277,7 +277,7 @@ def match_all (A : prop) (c1 : A : type -> (term A -> prop) -> certificate) (c2
(__ => __ => c2) (__ => __ => c2)
(__ => __ => c2). (__ => __ => c2).
def match_ex (A : prop) (c1 : A : type -> (term A -> prop) -> certificate) (c2 : certificate) : certificate := def match_ex (A : prop) (c1 : A : sort -> (term A -> prop) -> certificate) (c2 : certificate) : certificate :=
match_prop A match_prop A
c2 c2
(__ => __ => c2) (__ => __ => c2)
...@@ -376,47 +376,47 @@ def absurd : cert.certificate := ...@@ -376,47 +376,47 @@ def absurd : cert.certificate :=
destruct_imp P fol.false assumption (exact P p) (exfalso assumption)). destruct_imp P fol.false assumption (exact P p) (exfalso assumption)).
(; apply A B a c proves (B a) if c proves all A B ;) (; apply A B a c proves (B a) if c proves all A B ;)
def apply (A : type) (B : term A -> prop) (a : term A) : certificate -> certificate := def apply (A : sort) (B : term A -> prop) (a : term A) : certificate -> certificate :=
refine (all A B) (B a) (ab => fol.all_elim A B ab a). refine (all A B) (B a) (ab => fol.all_elim A B ab a).
(; destruct_all A B a c1 c2 proves G if c1 prove (all A B) and c2 (; destruct_all A B a c1 c2 proves G if c1 prove (all A B) and c2
proves imp (B a) G ;) proves imp (B a) G ;)
def destruct_all (A : type) (B : term A -> prop) def destruct_all (A : sort) (B : term A -> prop)
(a : term A) (c1 : certificate) (a : term A) (c1 : certificate)
(c2 : certificate) : certificate (c2 : certificate) : certificate
:= :=
with_goal (G => refine2 (all A B) (imp (B a) G) G (ab => f => fol.imp_elim (B a) G f (fol.all_elim A B ab a)) c1 c2). with_goal (G => refine2 (all A B) (imp (B a) G) G (ab => f => fol.imp_elim (B a) G f (fol.all_elim A B ab a)) c1 c2).
(; To delay the comparison of types, we define ifeq_type only when it is run ;) (; To delay the comparison of sorts, we define ifeq_sort only when it is run ;)
ifeq_type : A : type -> B : type -> ((term A -> term B) -> certificate) -> certificate -> certificate. ifeq_sort : A : sort -> B : sort -> ((term A -> term B) -> certificate) -> certificate -> certificate.
[G,B,A,f] run G B (ifeq_type A A f _) --> run G B (f (x => x)) [G,B,A,f] run G B (ifeq_sort A A f _) --> run G B (f (x => x))
[G,B,c] run G B (ifeq_type _ _ _ c) --> run G B c. [G,B,c] run G B (ifeq_sort _ _ _ c) --> run G B c.
ifeq_prop : A : prop -> B : prop -> ((proof A -> proof B) -> certificate) -> certificate -> certificate. ifeq_prop : A : prop -> B : prop -> ((proof A -> proof B) -> certificate) -> certificate -> certificate.
[G,B,A,f] run G B (ifeq_prop A A f _) --> run G B (f (x => x)) [G,B,A,f] run G B (ifeq_prop A A f _) --> run G B (f (x => x))
[G,B,c] run G B (ifeq_prop _ _ _ c) --> run G B c. [G,B,c] run G B (ifeq_prop _ _ _ c) --> run G B c.
(; exists A a c proves ex A B if c proves (B a) ;) (; exists A a c proves ex A B if c proves (B a) ;)
witness_of_bad_type : tac.exc. witness_of_bad_sort : tac.exc.
not_an_existential : tac.exc. not_an_existential : tac.exc.
def exists (A : type) (a : term A) (c : certificate) : certificate def exists (A : sort) (a : term A) (c : certificate) : certificate
:= :=
with_goal (G => with_goal (G =>
match_ex G match_ex G
(A' => B => (A' => B =>
ifeq_type A A' (f => ifeq_sort A A' (f =>
refine (B (f a)) refine (B (f a))
(fol.ex A' B) (fol.ex A' B)
(fol.ex_intro A' B (f a)) (fol.ex_intro A' B (f a))
c) c)
(raise witness_of_bad_type)) (raise witness_of_bad_sort))
(raise not_an_existential)). (raise not_an_existential)).
(; destruct_ex A B c1 c2 proves G |- C if c1 proves G |- ex A B and c2 (; destruct_ex A B c1 c2 proves G |- C if c1 proves G |- ex A B and c2
proves G,(a:A),B a |- C ;) proves G,(a:A),B a |- C ;)
def destruct_ex (A : type) (B : term A -> prop) (c1 : certificate) (c2 def destruct_ex (A : sort) (B : term A -> prop) (c1 : certificate) (c2
: certificate) : certificate : certificate) : certificate
:= :=
with_goal (G => with_goal (G =>
......
...@@ -83,7 +83,7 @@ def not_and_is_or_not (A : fol.prop) (B : fol.prop) : ...@@ -83,7 +83,7 @@ def not_and_is_or_not (A : fol.prop) (B : fol.prop) :
cert.assumption))). cert.assumption))).
(; Same for quantifiers ;) (; Same for quantifiers ;)
def not_all_is_ex_not (A : fol.type) (P : fol.term A -> fol.prop) : def not_all_is_ex_not (A : fol.sort) (P : fol.term A -> fol.prop) :
fol.proof (fol.imp (fol.not (fol.all A (x => P x))) fol.proof (fol.imp (fol.not (fol.all A (x => P x)))
(fol.ex A (x : fol.term A => fol.not (P x)))) (fol.ex A (x : fol.term A => fol.not (P x))))
:= :=
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
(; Certificates for manipulating equalities ;) (; Certificates for manipulating equalities ;)
def type := fol.type. def sort := fol.sort.
def term := fol.term. def term := fol.term.
def prop := fol.prop. def prop := fol.prop.
def proof := fol.proof. def proof := fol.proof.
...@@ -19,7 +19,7 @@ def imp := fol.imp. ...@@ -19,7 +19,7 @@ def imp := fol.imp.
def all := fol.all. def all := fol.all.
not_an_equality : tac.exc. not_an_equality : tac.exc.
def match_equality : prop -> (A : type -> term A -> term A -> certificate) -> certificate -> certificate. def match_equality : prop -> (A : sort -> term A -> term A -> certificate) -> certificate -> certificate.
[c] match_equality fol.false _ c --> c [c] match_equality fol.false _ c --> c
[c] match_equality (fol.and _ _) _ c --> c [c] match_equality (fol.and _ _) _ c --> c
...@@ -37,12 +37,12 @@ def match_equality : prop -> (A : type -> term A -> term A -> certificate) -> ce ...@@ -37,12 +37,12 @@ def match_equality : prop -> (A : type -> term A -> term A -> certificate) -> ce
--> c A a b --> c A a b
[c] match_equality (fol.apply_pred _ _) _ c --> c. [c] match_equality (fol.apply_pred _ _) _ c --> c.
not_convertible : A : type -> term A -> term A -> tac.exc. not_convertible : A : sort -> term A -> term A -> tac.exc.
(; reflexivity proves goals of the form a = a ;) (; reflexivity proves goals of the form a = a ;)
def reflexivity : certificate := def reflexivity : certificate :=
cert.with_goal (G => cert.with_goal (G =>
match_equality G (A : type => a : term A => b : term A => match_equality G (A : sort => a : term A => b : term A =>
cert.try (cert.exact (eq A a a) (fol.all_elim A (x => eq A x x) (eq.eq_refl A) a)) cert.try (cert.exact (eq A a a) (fol.all_elim A (x => eq A x x) (eq.eq_refl A) a))
(__ => cert.raise (not_convertible A a b)) (__ => cert.raise (not_convertible A a b))
) )
...@@ -51,7 +51,7 @@ def reflexivity : certificate := ...@@ -51,7 +51,7 @@ def reflexivity : certificate :=
(; symmetry c proves a = b if c proves b = a ;) (; symmetry c proves a = b if c proves b = a ;)
def symmetry (c : certificate) : certificate := def symmetry (c : certificate) : certificate :=
cert.with_goal (G => cert.with_goal (G =>
match_equality G (A : type => a : term A => b : term A => match_equality G (A : sort => a : term A => b : term A =>
cert.refine (eq A b a) cert.refine (eq A b a)
(eq A a b) (eq A a b)
(fol.imp_elim (eq A b a) (eq A a b) (fol.imp_elim (eq A b a) (eq A a b)
...@@ -63,10 +63,10 @@ def symmetry (c : certificate) : certificate := ...@@ -63,10 +63,10 @@ def symmetry (c : certificate) : certificate :=
trans_bad_type : tac.exc. trans_bad_type : tac.exc.
(; transitivity A b c1 c2 proves a = c if c1 proves a = b and c2 proves b = c ;) (; transitivity A b c1 c2 proves a = c if c1 proves a = b and c2 proves b = c ;)
def transitivity (A : type) (b : term A) (c1 : certificate) (c2 : certificate) : certificate := def transitivity (A : sort) (b : term A) (c1 : certificate) (c2 : certificate) : certificate :=
cert.with_goal (G => cert.with_goal (G =>
match_equality G (A' : type => a : term A' => c : term A' => match_equality G (A' : sort => a : term A' => c : term A' =>
cert.ifeq_type A A' (f => cert.ifeq_sort A A' (f =>
cert.refine2 (eq A' a (f b)) cert.refine2 (eq A' a (f b))
(eq A' (f b) c) (eq A' (f b) c)
(eq A' a c) (eq A' a c)
...@@ -98,20 +98,20 @@ def match_f_equal_goal : prop -> ...@@ -98,20 +98,20 @@ def match_f_equal_goal : prop ->
c c
--> c f as bs. --> c f as bs.
certificates : fol.types -> Type. certificates : fol.sorts -> Type.
nil_cert : certificates fol.nil_type. nil_cert : certificates fol.nil_sort.
cons_cert : A : type -> As : fol.types -> certificate -> certificates As -> certificates (fol.cons_type A As). cons_cert : A : sort -> As : fol.sorts -> certificate -> certificates As -> certificates (fol.cons_sort A As).
def ifeq_certs : L : fol.types -> def ifeq_certs : L : fol.sorts ->
L' : fol.types -> L' : fol.sorts ->
certificates L -> certificates L ->
certificates L'. certificates L'.
[L,c] ifeq_certs L L c --> c. [L,c] ifeq_certs L L c --> c.
(; f_equal_fun L B f [a1 .. an] [b1 .. bn] [c1 .. cn] proves (; f_equal_fun L B f [a1 .. an] [b1 .. bn] [c1 .. cn] proves
f [a1 .. an] = f [b1 .. bn] if each ci proves ai = bi ;) f [a1 .. an] = f [b1 .. bn] if each ci proves ai = bi ;)
def f_equal_fun : L : fol.types -> def f_equal_fun : L : fol.sorts ->
B : type -> B : sort ->
(fol.terms L -> term B) -> (fol.terms L -> term B) ->
fol.terms L -> fol.terms L ->
fol.terms L -> fol.terms L ->
...@@ -119,7 +119,7 @@ def f_equal_fun : L : fol.types -> ...@@ -119,7 +119,7 @@ def f_equal_fun : L : fol.types ->
[] f_equal_fun _ _ _ fol.nil_term fol.nil_term nil_cert --> reflexivity [] f_equal_fun _ _ _ fol.nil_term fol.nil_term nil_cert --> reflexivity
[B,f,A,a,As,as,b,bs,c,cs] [B,f,A,a,As,as,b,bs,c,cs]
f_equal_fun f_equal_fun
(fol.cons_type _ _) (fol.cons_sort _ _)
B B
f f
(fol.cons_term A a As as) (fol.cons_term A a As as)
...@@ -145,7 +145,7 @@ def f_equal_fun : L : fol.types -> ...@@ -145,7 +145,7 @@ def f_equal_fun : L : fol.types ->
c c
(f_equal_fun As B (l => f (fol.cons_term A a As l)) as bs cs). (f_equal_fun As B (l => f (fol.cons_term A a As l)) as bs cs).
def f_equal_fun_on_goal (L : fol.types) (cs : certificates L) : certificate def f_equal_fun_on_goal (L : fol.sorts) (cs : certificates L) : certificate
:= :=
cert.with_goal (G => match_f_equal_goal G cert.with_goal (G => match_f_equal_goal G
(f => as => bs => (f => as => bs =>
...@@ -156,50 +156,50 @@ def f_equal_fun_on_goal (L : fol.types) (cs : certificates L) : certificate ...@@ -156,50 +156,50 @@ def f_equal_fun_on_goal (L : fol.types) (cs : certificates L) : certificate
as bs (ifeq_certs L (fol.fun_arity f) cs) as bs (ifeq_certs L (fol.fun_arity f) cs)
)). )).
def f_equal_T : fol.types -> Type. def f_equal_T : fol.sorts -> Type.
[] f_equal_T fol.nil_type --> certificate [] f_equal_T fol.nil_sort --> certificate
[As] f_equal_T (fol.cons_type _ As) --> certificate -> f_equal_T As. [As] f_equal_T (fol.cons_sort _ As) --> certificate -> f_equal_T As.
def append_type : fol.types -> fol.types -> fol.types. def append_type : fol.sorts -> fol.sorts -> fol.sorts.
[As] append_type As fol.nil_type --> As [As] append_type As fol.nil_sort --> As
[As,B,Bs] [As,B,Bs]
append_type As (fol.cons_type B Bs) --> append_type As (fol.cons_sort B Bs) -->
append_type (fol.snoc_type As B) Bs. append_type (fol.snoc_sort As B) Bs.
def snoc_cert : L : fol.types -> def snoc_cert : L : fol.sorts ->
A : type -> A : sort ->
certificates L -> certificates L ->
certificate -> certificate ->
certificates (fol.snoc_type L A). certificates (fol.snoc_sort L A).
[A,c] snoc_cert _ A nil_cert c --> cons_cert A fol.nil_type c nil_cert [A,c] snoc_cert _ A nil_cert c --> cons_cert A fol.nil_sort c nil_cert
[A,B,Bs,c,cs,ca] [A,B,Bs,c,cs,ca]
snoc_cert (fol.cons_type _ _) A (cons_cert B Bs c cs) ca snoc_cert (fol.cons_sort _ _) A (cons_cert B Bs c cs) ca
--> -->
cons_cert B (fol.snoc_type Bs A) c (snoc_cert Bs A cs ca). cons_cert B (fol.snoc_sort Bs A) c (snoc_cert Bs A cs ca).
def f_equal_fun_n : L' : fol.types -> def f_equal_fun_n : L' : fol.sorts ->
L : fol.types -> L : fol.sorts ->
certificates L -> certificates L ->
f_equal_T L'. f_equal_T L'.
[L,B,f,as,bs,cs] [L,B,f,as,bs,cs]
f_equal_fun_n fol.nil_type L cs f_equal_fun_n fol.nil_sort L cs
--> -->
f_equal_fun_on_goal L cs f_equal_fun_on_goal L cs
[A,As,L,B,f,as,bs,cs] [A,As,L,B,f,as,bs,cs]
f_equal_fun_n (fol.cons_type A As) L cs f_equal_fun_n (fol.cons_sort A As) L cs
--> -->
c : certificate => c : certificate =>
f_equal_fun_n As (fol.snoc_type L A) (snoc_cert L A cs c). f_equal_fun_n As (fol.snoc_sort L A) (snoc_cert L A cs c).
def f_equal (f : fol.function) := def f_equal (f : fol.function) :=
f_equal_fun_n f_equal_fun_n
(fol.fun_arity f) (fol.fun_arity f)
fol.nil_type fol.nil_sort
nil_cert. nil_cert.
(; rewrite A a b c1 c2 proves G if c1 proves a = b and c2 proves G{b/a} ;) (; rewrite A a b c1 c2 proves G if c1 proves a = b and c2 proves G{b/a} ;)
def rewrite (A : type) (a : term A) (b : term A) (c1 : certificate) (c2 : certificate) : certificate def rewrite (A : sort) (a : term A) (b : term A) (c1 : certificate) (c2 : certificate) : certificate
:= :=
cert.with_goal (G => cert.with_goal (G =>
cert.refine2 (eq A a b) cert.refine2 (eq A a b)
......
This diff is collapsed.
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
- no deep manipulation of variables and meta variables - no deep manipulation of variables and meta variables
;) ;)
def type := fol.type.