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

type -> sort

parent 0d0c865f
#NAME NUM343_1.
def type := fol.type.
def sort := fol.sort.
def term := fol.term.
def prop := fol.prop.
def proof := fol.proof.
......@@ -15,19 +15,19 @@ def predicate := fol.predicate.
def function := fol.function.
def pred_apply := fol.pred_apply.
def fun_apply := fol.fun_apply.
def read_types := fol.read_types.
def nil_type := fol.nil_type.
def read_sorts := fol.read_sorts.
def nil_sort := fol.nil_sort.
def 0 := nat.O.
def 1 := nat.S 0.
def 2 := nat.S 1.
(; Signature ;)
A : type.
A : sort.
LEQ : predicate.
[] fol.pred_arity LEQ --> read_types 2 A A.
[] fol.pred_arity LEQ --> read_sorts 2 A A.
N : function.
[] fol.fun_arity N --> nil_type.
[] fol.fun_arity N --> nil_sort.
[] fol.fun_codomain N --> A.
def leq : term A -> term A -> prop := pred_apply LEQ.
......
......@@ -7,18 +7,18 @@
(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
of type BAR. Let's call it Joe. ;)
of sort BAR. Let's call it Joe. ;)
JOE : fol.function.
[] fol.fun_arity JOE --> fol.nil_type.
[] fol.fun_arity JOE --> fol.nil_sort.
[] fol.fun_codomain JOE --> BAR.
def Joe : fol.term BAR := fol.fun_apply JOE.
(; The "drink" 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 drinker_statement : fol.prop :=
......@@ -50,7 +50,7 @@ def drinker_paradox : fol.proof drinker_statement :=
(cert.with_assumption (E => e =>
cert.destruct_ex BAR ndrink (cert.exact E e)
(; ¬∀, ∃¬, 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
(; ¬∀, ∃¬, John, ¬drink John ⊢ drink John → ∀ ;)
(cert.intro cert.absurd)))))))).
#NAME resolution_examples.
def type := fol.type.
def sort := fol.sort.
def term := fol.term.
def prop := fol.prop.
def proof := fol.proof.
......@@ -15,21 +15,21 @@ def predicate := fol.predicate.
def function := fol.function.
def pred_apply := fol.pred_apply.
def fun_apply := fol.fun_apply.
def read_types := fol.read_types.
def nil_type := fol.nil_type.
def read_sorts := fol.read_sorts.
def nil_sort := fol.nil_sort.
def 0 := nat.O.
def 1 := nat.S 0.
(; Signature ;)
A : type.
A : sort.
P : predicate.
[] fol.pred_arity P --> read_types 1 A.
[] fol.pred_arity P --> read_sorts 1 A.
O : function.
[] fol.fun_arity O --> nil_type.
[] fol.fun_arity O --> nil_sort.
[] fol.fun_codomain O --> A.
S : function.
[] fol.fun_arity S --> read_types 1 A.
[] fol.fun_arity S --> read_sorts 1 A.
[] fol.fun_codomain S --> A.
def p : term A -> prop := pred_apply P.
......
......@@ -13,4 +13,4 @@ cons_clause : litteral -> clause -> clause.
qclause : Type.
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.
def type := fol.type.
def types := fol.types.
def sort := fol.sort.
def sorts := fol.sorts.
def term := fol.term.
def terms := fol.terms.
def nil_term := fol.nil_term.
def cons_term := fol.cons_term.
def read_types := fol.read_types.
def read_sorts := fol.read_sorts.
def prop := fol.prop.
def imp := fol.imp.
......@@ -27,21 +27,21 @@ def O := nat.O.
def S := nat.S.
(; Equality is a family of binary predicate symbols. ;)
Eq : type -> predicate.
[A] fol.pred_arity (Eq A) --> read_types (S (S O)) A A.
Eq : sort -> predicate.
[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]
fol.proof (fol.apply_pred (Eq A)
(fol.cons_term _ x _ (fol.cons_term _ y _ fol.nil_term))) -->
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).
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 =>
all A (y : term A =>
imp (eq A y x) (eq A x y)))) :=
......@@ -50,7 +50,7 @@ def eq_symm (A : type) :
(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)))).
def eq_trans (A : type) :
def eq_trans (A : sort) :
proof (all A (x : term A =>
all A (y : term A =>
all A (z : term A =>
......@@ -64,7 +64,7 @@ def eq_trans (A : type) :
(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))))).
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 =>
all A (y : term A =>
imp (eq A x y) (imp (p x) (p y))))) :=
......@@ -74,21 +74,21 @@ def eq_p_equal (A : type) (p : term A -> prop) :
(Hxy => fol.imp_intro (p x) (p y)
(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 =>
all A (y : term A =>
imp (eq A x y) (eq B (f x) (f y))))).
def pred_imp : L : types -> (terms L -> prop) -> (terms L -> prop) -> prop.
[p,q] pred_imp fol.nil_type p q --> imp (p nil_term) (q nil_term)
[A,L,p,q] pred_imp (fol.cons_type A L) p q -->
def pred_imp : L : sorts -> (terms L -> prop) -> (terms L -> prop) -> prop.
[p,q] pred_imp fol.nil_sort p q --> imp (p nil_term) (q nil_term)
[A,L,p,q] pred_imp (fol.cons_sort A L) p q -->
all A (x : 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))))).
def eq_pred_imp : L : types -> 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)
[A,L,p] eq_pred_imp (fol.cons_type A L) p -->
def eq_pred_imp : L : sorts -> p : (terms L -> prop) -> proof (pred_imp L p p).
[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_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)))))
(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))))
......@@ -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))
:= 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.
[B,b,b'] fun_eq fol.nil_type 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' -->
def fun_eq : L : sorts -> B : sort -> (terms L -> term B) -> (terms L -> term B) -> prop.
[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_sort A L) B f f' -->
all A (x : 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))))).
def eq_fun_eq : L : types -> B : type -> 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)
[A,L,B,f,f'] eq_fun_eq (fol.cons_type A L) B 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_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_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)))))
(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))))
......
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 ;)
(; There is just one sort representing natural numbers ;)
Nat : fol.type.
Nat : fol.sort.
(; There is just one predicate symbol for equality ;)
EQ : fol.predicate.
......@@ -21,10 +21,10 @@ ONE : fol.function.
ADD : fol.function.
(; Arities ;)
[] fol.pred_arity EQ --> fol.read_types (nat.S (nat.S nat.O)) Nat Nat.
[] fol.fun_arity ZERO --> fol.nil_type.
[] fol.fun_arity ONE --> fol.nil_type.
[] fol.fun_arity ADD --> 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_sort.
[] fol.fun_arity ONE --> fol.nil_sort.
[] fol.fun_arity ADD --> fol.read_sorts (nat.S (nat.S nat.O)) Nat Nat.
[] fol.fun_codomain ZERO --> Nat.
[] fol.fun_codomain ONE --> Nat.
[] fol.fun_codomain ADD --> Nat.
......
This diff is collapsed.
......@@ -8,7 +8,7 @@
;)
def type := fol.type.
def sort := fol.sort.
def term := fol.term.
def prop := fol.prop.
def proof := fol.proof.
......@@ -17,7 +17,7 @@ def imp := fol.imp.
context : Type.
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.
certificate : Type.
......@@ -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.
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 -->
with_goal (A =>
with_context (G =>
......@@ -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
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).
......@@ -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.
(; 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.
def fix_prop : ((prop -> certificate) -> prop -> certificate) -> prop -> certificate.
......@@ -212,8 +212,8 @@ def match_prop : prop ->
(prop -> prop -> certificate) -> (; and ;)
(prop -> prop -> certificate) -> (; or ;)
(prop -> prop -> certificate) -> (; imp ;)
(A : type -> (term A -> prop) -> certificate) -> (; all ;)
(A : type -> (term A -> prop) -> certificate) -> (; ex ;)
(A : sort -> (term A -> prop) -> certificate) -> (; all ;)
(A : sort -> (term A -> prop) -> certificate) -> (; ex ;)
(p : fol.predicate ->
fol.terms (fol.pred_arity p) ->
certificate) ->
......@@ -267,7 +267,7 @@ def match_imp (A : prop) (c1 : prop -> prop -> certificate) (c2 : certificate) :
(__ => __ => 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
c2
(__ => __ => c2)
......@@ -277,7 +277,7 @@ def match_all (A : prop) (c1 : A : type -> (term A -> prop) -> certificate) (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
c2
(__ => __ => c2)
......@@ -376,47 +376,47 @@ def absurd : cert.certificate :=
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 ;)
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).
(; destruct_all A B a c1 c2 proves G if c1 prove (all A B) and c2
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)
(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).
(; To delay the comparison of types, we define ifeq_type only when it is run ;)
ifeq_type : A : type -> B : type -> ((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,c] run G B (ifeq_type _ _ _ c) --> run G B c.
(; To delay the comparison of sorts, we define ifeq_sort only when it is run ;)
ifeq_sort : A : sort -> B : sort -> ((term A -> term B) -> certificate) -> certificate -> certificate.
[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_sort _ _ _ c) --> run G B c.
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,c] run G B (ifeq_prop _ _ _ c) --> run G B c.
(; 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.
def exists (A : type) (a : term A) (c : certificate) : certificate
def exists (A : sort) (a : term A) (c : certificate) : certificate
:=
with_goal (G =>
match_ex G
(A' => B =>
ifeq_type A A' (f =>
ifeq_sort A A' (f =>
refine (B (f a))
(fol.ex A' B)
(fol.ex_intro A' B (f a))
c)
(raise witness_of_bad_type))
(raise witness_of_bad_sort))
(raise not_an_existential)).
(; 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 ;)
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
:=
with_goal (G =>
......
......@@ -83,7 +83,7 @@ def not_and_is_or_not (A : fol.prop) (B : fol.prop) :
cert.assumption))).
(; 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.ex A (x : fol.term A => fol.not (P x))))
:=
......
......@@ -9,7 +9,7 @@
(; Certificates for manipulating equalities ;)
def type := fol.type.
def sort := fol.sort.
def term := fol.term.
def prop := fol.prop.
def proof := fol.proof.
......@@ -19,7 +19,7 @@ def imp := fol.imp.
def all := fol.all.
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.and _ _) _ c --> c
......@@ -37,12 +37,12 @@ def match_equality : prop -> (A : type -> term A -> term A -> certificate) -> ce
--> c A a b
[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 ;)
def reflexivity : certificate :=
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.raise (not_convertible A a b))
)
......@@ -51,7 +51,7 @@ def reflexivity : certificate :=
(; symmetry c proves a = b if c proves b = a ;)
def symmetry (c : certificate) : certificate :=
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)
(eq A a b)
(fol.imp_elim (eq A b a) (eq A a b)
......@@ -63,10 +63,10 @@ def symmetry (c : certificate) : certificate :=
trans_bad_type : tac.exc.
(; 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 =>
match_equality G (A' : type => a : term A' => c : term A' =>
cert.ifeq_type A A' (f =>
match_equality G (A' : sort => a : term A' => c : term A' =>
cert.ifeq_sort A A' (f =>
cert.refine2 (eq A' a (f b))
(eq A' (f b) c)
(eq A' a c)
......@@ -98,20 +98,20 @@ def match_f_equal_goal : prop ->
c
--> c f as bs.
certificates : fol.types -> Type.
nil_cert : certificates fol.nil_type.
cons_cert : A : type -> As : fol.types -> certificate -> certificates As -> certificates (fol.cons_type A As).
certificates : fol.sorts -> Type.
nil_cert : certificates fol.nil_sort.
cons_cert : A : sort -> As : fol.sorts -> certificate -> certificates As -> certificates (fol.cons_sort A As).
def ifeq_certs : L : fol.types ->
L' : fol.types ->
def ifeq_certs : L : fol.sorts ->
L' : fol.sorts ->
certificates L ->
certificates L'.
[L,c] ifeq_certs L L c --> c.
(; 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 ;)
def f_equal_fun : L : fol.types ->
B : type ->
def f_equal_fun : L : fol.sorts ->
B : sort ->
(fol.terms L -> term B) ->
fol.terms L ->
fol.terms L ->
......@@ -119,7 +119,7 @@ def f_equal_fun : L : fol.types ->
[] f_equal_fun _ _ _ fol.nil_term fol.nil_term nil_cert --> reflexivity
[B,f,A,a,As,as,b,bs,c,cs]
f_equal_fun
(fol.cons_type _ _)
(fol.cons_sort _ _)
B
f
(fol.cons_term A a As as)
......@@ -145,7 +145,7 @@ def f_equal_fun : L : fol.types ->
c
(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
(f => as => bs =>
......@@ -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)
)).
def f_equal_T : fol.types -> Type.
[] f_equal_T fol.nil_type --> certificate
[As] f_equal_T (fol.cons_type _ As) --> certificate -> f_equal_T As.
def f_equal_T : fol.sorts -> Type.
[] f_equal_T fol.nil_sort --> certificate
[As] f_equal_T (fol.cons_sort _ As) --> certificate -> f_equal_T As.
def append_type : fol.types -> fol.types -> fol.types.
[As] append_type As fol.nil_type --> As
def append_type : fol.sorts -> fol.sorts -> fol.sorts.
[As] append_type As fol.nil_sort --> As
[As,B,Bs]
append_type As (fol.cons_type B Bs) -->
append_type (fol.snoc_type As B) Bs.
append_type As (fol.cons_sort B Bs) -->
append_type (fol.snoc_sort As B) Bs.
def snoc_cert : L : fol.types ->
A : type ->
def snoc_cert : L : fol.sorts ->
A : sort ->
certificates L ->
certificate ->
certificates (fol.snoc_type L A).
[A,c] snoc_cert _ A nil_cert c --> cons_cert A fol.nil_type c nil_cert
certificates (fol.snoc_sort L A).
[A,c] snoc_cert _ A nil_cert c --> cons_cert A fol.nil_sort c nil_cert
[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 ->
L : fol.types ->
def f_equal_fun_n : L' : fol.sorts ->
L : fol.sorts ->
certificates L ->
f_equal_T L'.
[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
[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 =>
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) :=
f_equal_fun_n
(fol.fun_arity f)
fol.nil_type
fol.nil_sort
nil_cert.
(; 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.refine2 (eq A a b)
......
This diff is collapsed.
......@@ -15,7 +15,7 @@
- no deep manipulation of variables and meta variables
;)
def type := fol.type.
def sort := fol.sort.
def term := fol.term.
def prop := fol.prop.
def proof := fol.proof.
......@@ -40,7 +40,7 @@ def try : A : prop -> tactic A -> (exc -> tactic A) -> tactic A.
[A,t] try A (ret _ t) _ --> ret A t
[t,f] try _ (raise _ t) f --> f t.
def fix_term : A : type ->
def fix_term : A : sort ->
B : (term A -> prop) ->
((x : term A -> tactic (B x)) -> x : term A -> tactic (B x)) ->
x : term A -> tactic (B x).
......@@ -52,7 +52,7 @@ def fix_proof : A : prop ->
proof A -> tactic B.
[A,B,f,t] fix_proof A B f t --> f (fix_proof A B f) t.
def intro_term : A : type ->
def intro_term : A : sort ->
B : (term A -> prop) ->
(x : term A -> tactic (B x)) ->
tactic (all A B).
......
......@@ -7,12 +7,12 @@
(setq-local dedukti-compile-options '("-nc" "-e" "-nl" "-I" "../fol"))
;)
def type := fol.type.
def sort := fol.sort.
def term := fol.term.
def prop := fol.prop.
def types := fol.types.
def nil_type := fol.nil_type.
def cons_type := fol.cons_type.
def sorts := fol.sorts.
def nil_sort := fol.nil_sort.
def cons_sort := fol.cons_sort.
def terms := fol.terms.
def nil_term := fol.nil_term.
def cons_term := fol.cons_term.
......@@ -29,20 +29,20 @@ def apply_fun := fol.apply_fun.
def fun_apply := fol.fun_apply.
def fun_arity := fol.fun_arity.
def function := fol.function.
def read_types := fol.read_types.
def read_sorts := fol.read_sorts.
def proof := fol.proof.
substitution : Type.
empty_subst : substitution.
cons_subst : A : type ->
cons_subst : A : sort ->
term A ->
term A ->
substitution ->
substitution.
def subst_prop : substitution -> prop -> prop.
def subst_term : substitution -> B : type -> term B -> term B.
def subst_terms : substitution -> Bs : types -> terms Bs -> terms Bs.
def subst_term : substitution -> B : sort -> term B -> term B.
def subst_terms : substitution -> Bs : sorts -> terms Bs -> terms Bs.
def subst_proof : s : substitution -> A : prop -> proof A -> proof (subst_prop s A).
def subst_proof_rev : s : substitution -> A : prop -> proof (subst_prop s A) -> proof A.
......@@ -132,24 +132,24 @@ def subst_proof_rev : s : substitution -> A : prop -> proof (subst_prop s A) ->
(; This is technically the same type as substitution
list (Σ A : type. term A * term A)
(; This is technically the same sort as substitution
list (Σ A : sort. term A * term A)
We keep them separate because they serve different purposes.
;)
unify_problem : Type.
unify_nil : unify_problem.
unify_cons : A : type -> term A -> term A -> unify_problem -> unify_problem.
unify_cons : A : sort -> term A -> term A -> unify_problem -> unify_problem.
unify_result : Type.
unify_success : substitution -> unify_result.
unify_failure : unify_result.
def unify_cons_terms : As : types -> terms As -> terms As -> unify_problem -> unify_problem.
[pb] unify_cons_terms fol.nil_type fol.nil_term fol.nil_term pb --> pb
def unify_cons_terms : As : sorts -> terms As -> terms As -> unify_problem -> unify_problem.
[pb] unify_cons_terms fol.nil_sort fol.nil_term fol.nil_term pb --> pb
[A,As,a,as,a',as',pb]
unify_cons_terms
(fol.cons_type A As)
(fol.cons_sort A As)
(fol.cons_term _ a _ as)
(fol.cons_term _ a' _ as')
pb
......@@ -165,8 +165,8 @@ def bor : bool -> bool -> bool.
[] bor bfalse btrue --> btrue
[] bor bfalse bfalse --> bfalse.
def occur : A : type -> term A -> B : type -> term B -> bool.
def occur_terms : A : type -> term A -> Bs : types -> terms Bs -> bool.
def occur : A : sort -> term A -> B : sort -> term B -> bool.
def occur_terms : A : sort -> term A -> Bs : sorts -> terms Bs -> bool.
[x] occur _ x _ x --> btrue
[A,x,f,l] occur A x _ (fol.apply_fun f l) --> occur_terms A x (fun_arity f) l
[] occur _ _ _ _ --> bfalse.
......@@ -176,8 +176,8 @@ def occur_terms : A : type -> term A -> Bs : types -> terms Bs -> bool.
bor (occur A x B b) (occur_terms A x Bs bs).
def unify : unify_problem -> unify_result.
def unify_occur : unify_problem -> A : type -> term A -> term A -> bool -> unify_result -> unify_result.
def subst_in_unify_problem : A : type -> term A -> term A -> unify_problem -> unify_problem.
def unify_occur : unify_problem -> A : sort -> term A -> term A -> bool -> unify_result -> unify_result.
def subst_in_unify_problem : A : sort -> term A -> term A -> unify_problem -> unify_problem.
[] unify unify_nil --> unify_success empty_subst
[f,l,l',pb] unify (unify_cons _ (fol.apply_fun f l) (fol.apply_fun f l') pb) -->
unify (unify_cons_terms (fun_arity f) l l' pb)
......@@ -209,17 +209,17 @@ def unify' (pb : unify_problem) :=
unify'_aux pb (unify pb).
A : type.
A : sort.
f : function.
[] fol.fun_arity f --> read_types (nat.S (nat.S nat.O)) A A.
[] fol.fun_arity f --> read_sorts (nat.S (nat.S nat.O)) A A.
[] fol.fun_codomain f --> A.
a : function.
[] fol.fun_arity a --> read_types nat.O.
[] fol.fun_arity a --> read_sorts nat.O.
[] fol.fun_codomain a --> A.
b : function.
[] fol.fun_arity b --> read_types nat.O.
[] fol.fun_arity b --> read_sorts nat.O.
[] fol.fun_codomain b --> A.
x : term A.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment