Skip to content
This repository was archived by the owner on Oct 14, 2021. It is now read-only.

Commit 39daf18

Browse files
committed
commit
1 parent a135190 commit 39daf18

File tree

9 files changed

+163
-44
lines changed

9 files changed

+163
-44
lines changed

src/index.js

+10-5
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const ident2sym = require('./ident2sym');
1212
const Expr = require('../theorems/expr');
1313
const debug = require('./debug');
1414

15-
const PRETTY_LOG = 1;
15+
const PRETTY_LOG = 0;
1616

1717
const {tilde} = parser;
1818
const {isSym, isPair} = database;
@@ -98,7 +98,7 @@ const verify = (thName, force=0, db=null) => {
9898
args.length !== 0 ? ` --- ${
9999
args.map(arg => info2str(arg)).join(`,${
100100
' '.repeat(2)}`)}` : ''}`;
101-
}).join('\n');
101+
}).join('\n\n');
102102
};
103103

104104
const reduce = function*(info){
@@ -122,7 +122,10 @@ const verify = (thName, force=0, db=null) => {
122122
return db.reduceToItself(info);
123123

124124
const err = msg => {
125-
error(`${msg}\n\n${info2str(info)}\n\n${getStackTrace()}`);
125+
log(`${msg}\n\n${info2str(info)}`);
126+
O.logb();
127+
log(getStackTrace());
128+
O.exit();
126129
};
127130

128131
const {cases} = func;
@@ -350,8 +353,10 @@ const info2str = info => {
350353
return `~${a}`;
351354
}
352355

353-
if(op === 'Proof')
354-
return O.tco(info2str, expr[1]);
356+
if(op === 'Proof'){
357+
const a = yield [info2str, expr[1], 1];
358+
return `|- ${a}`;
359+
}
355360
}
356361

357362
if(isSym(expr))

system/core/funcs/assert.drift

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
assert True = id
22

3-
assertEq a b = assert (eq a b)
3+
assert.fail = assert false
4+
5+
assert.eq a b = assert (eq a b)

system/core/types/proof.drift

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ Proof:
44

55
rule.mp (Proof (Impl a b)) (Proof a) = Proof b
66

7-
rule.uni.intr_ (Proof (Impl a b)) (Nat c) = assert (not (hasIdent c a))
7+
rule.uni.intr_ (Nat c) (Proof (Impl a b)) = assert (not (hasIdent c a))
88
(Proof (impl a (forall c b)))
99

10-
rule.uni.elim_ (Proof (Impl a (Forall b c))) (Nat d) =
10+
rule.uni.elim_ (Nat d) (Proof (Impl a (Forall b c))) =
1111
Proof (impl a (substIdentStrict b d c))
1212

1313
ax.prop.1 = Proof (impl phi (impl psi phi))
@@ -19,5 +19,5 @@ Proof:
1919
ax.prop.3 = Proof (impl (impl (pnot phi) (pnot psi)) (impl psi phi))
2020

2121
rule.inst a b c = rule.inst_ a b (pred c)
22-
rule.uni.intr a b = rule.uni.intr_ a (nat b)
23-
rule.uni.elim a b = rule.uni.elim_ a (nat b)
22+
rule.uni.intr a b = rule.uni.intr_ (nat a) b
23+
rule.uni.elim a b = rule.uni.elim_ (nat a) b

system/funcs/pred.drift

+23-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,26 @@
11
implr a = impl a a
22

33
iff = synt.iff
4-
iffr a = iff a a
4+
iffr a = iff a a
5+
6+
op2pair func pred = op2pair_opPair (func phi psi) pred (pair nil nil)
7+
op2pair_opPair &phi pred (Pair Nil a) = pair pred a
8+
op2pair_opPair &phi pred (Pair pred a) = pair pred a
9+
op2pair_opPair &psi pred (Pair a Nil) = pair a pred
10+
op2pair_opPair &psi pred (Pair a pred) = pair a pred
11+
op2pair_opPair (Impl a1 b1) (Impl a2 b2) opPair = op2pair_opPair b1 b2 (op2pair_opPair a1 a2 opPair)
12+
op2pair_opPair (Pnot a1) (Pnot a2) opPair = op2pair_opPair a1 a2 opPair
13+
op2pair_opPair (Forall a b1) (Forall a b2) opPair = op2pair_opPair b1 b2 opPair
14+
op2pair_opPair (Pelem a b) (Pelem a b) opPair = opPair
15+
16+
impl2pair (Impl a b) = pair a b
17+
or2pair = op2pair synt.or
18+
and2pair = op2pair synt.and
19+
iff2pair = op2pair iff
20+
21+
hasSubPred sub sub = true
22+
hasSubPred sub (Pident *) = false
23+
hasSubPred sub (Impl a b) = or (hasSubPred sub a) (hasSubPred sub b)
24+
hasSubPred sub (Pnot a) = hasSubPred sub a
25+
hasSubPred sub (Forall * a) = hasSubPred sub a
26+
hasSubPred sub (Pelem * *) = false

system/theorems/prop/basic.drift

+15-1
Original file line numberDiff line numberDiff line change
@@ -256,4 +256,18 @@ th.prop.a.-a.b_ a = util.addSup2 a
256256
(pnot phi)
257257

258258
-- ~a -> a -> b
259-
th.prop.-a.a.b = util.reord th.prop.a.-a.b
259+
th.prop.-a.a.b = util.reord th.prop.a.-a.b
260+
261+
-- T <-> Ɐa (a = a)
262+
th.true.def = prove.taut
263+
(synt.iff synt.true (forall a. (synt.eq a. a.)))
264+
265+
-- ⊥ <-> ~T
266+
th.false.def = prove.taut
267+
(synt.iff synt.false (pnot synt.true))
268+
269+
-- T
270+
th.true = prove.taut synt.true
271+
272+
-- ~⊥
273+
th.nfalse = prove.taut (pnot synt.false)

system/theorems/prop/eq.drift

+41-25
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,47 @@
11
-- Ɐa Ɐb (a = b <-> Ɐc (c ∈ a <-> c ∈ b) ^ Ɐc (a ∈ c <-> b ∈ c))
2-
th.eq.def = util.uni.intr
3-
(util.uni.intr
4-
(util.iff.refl (synt.eq a. b.))
5-
b.)
6-
a.
2+
th.eq.def = util.uni.intr a.
3+
(util.uni.intr b.
4+
(util.iff.refl (synt.eq a. b.)))
75

86
-- Ɐa (a = a)
9-
th.eq.refl = util.uni.intr
7+
th.eq.refl = util.uni.intr a.
108
(util.and
11-
(util.uni.intr
12-
(util.iff.refl (pelem b. a.))
13-
b.)
14-
(util.uni.intr
15-
(util.iff.refl (pelem a. b.))
16-
b.))
17-
a.
9+
(util.uni.intr b.
10+
(util.iff.refl (pelem b. a.)))
11+
(util.uni.intr b.
12+
(util.iff.refl (pelem a. b.))))
1813

19-
-- T <-> Ɐa (a = a)
20-
th.true.def = prove.taut
21-
(synt.iff synt.true (forall a. (synt.eq a. a.)))
14+
----------------------------------------------------------------------------------------------------
2215

23-
-- ⊥ <-> ~T
24-
th.false.def = prove.taut
25-
(synt.iff synt.false (pnot synt.true))
26-
27-
-- T
28-
th.true = prove.taut synt.true
29-
30-
-- ~⊥
31-
th.nfalse = prove.taut (pnot synt.false)
16+
-- th_a = id
17+
-- (util.and
18+
-- (util.uni.intr b.
19+
-- (util.iff.refl (pelem b. a.)))
20+
-- (util.uni.intr b.
21+
-- (util.iff.refl (pelem a. b.))))
22+
--
23+
-- th_b = id
24+
-- (util.and
25+
-- (util.uni.intr a.
26+
-- (util.iff.refl (pelem a. b.)))
27+
-- (util.uni.intr a.
28+
-- (util.iff.refl (pelem b. a.))))
29+
--
30+
-- iff_ab = util.infer2
31+
-- (prove.taut (impl phi
32+
-- (impl psi (synt.iff phi psi))))
33+
-- th_a
34+
-- th_b
35+
--
36+
-- th1 = util.uni.intr c.
37+
-- (util.infer
38+
-- (rule.inst
39+
-- (prove.taut (impl phi (synt.or phi psi)))
40+
-- psi (pelem c. d.))
41+
-- th_a)
42+
--
43+
-- test = rule.mp
44+
-- (util.infer
45+
-- th.prop.iff.def.2
46+
-- (util.subst (extract th1) iff_ab))
47+
-- th1

system/util/prop.drift

+8
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ util.infer proofImpl:(Proof (Impl a b)) proofPremise = rule.mp
3939
(util.inst proofImpl (autoPidentPredPairs a (extract proofPremise)))
4040
proofPremise
4141

42+
util.infer2 proofImpl proofPrem1 proofPrem2 = util.infer
43+
(util.infer proofImpl proofPrem1)
44+
proofPrem2
45+
46+
util.infer3 proofImpl proofPrem1 proofPrem2 proofPrem3 = util.infer
47+
(util.infer2 proofImpl proofPrem1 proofPrem2)
48+
proofPrem3
49+
4250
util.infer.ax2 = util.infer th.prop.ax2
4351
util.infer.ax3 = util.infer th.prop.ax3
4452
util.infer.mpt = util.infer th.prop.mpt

system/util/quant.drift

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
util.uni.intr proof:(Proof pred) ident =
2-
util.uni.intr_ proof ident (availIdent pred)
3-
util.uni.intr_ proof ident avail = rule.mp
4-
(rule.uni.intr
1+
util.uni.intr ident proof:(Proof pred) =
2+
util.uni.intr_ ident (availIdent pred) proof
3+
util.uni.intr_ ident avail proof = rule.mp
4+
(rule.uni.intr ident
55
(util.addSup
66
proof
7-
(implr (pelem avail avail)))
8-
ident)
7+
(implr (pelem avail avail))))
98
(util.impl.refl (pelem avail avail))

system/util/subst.drift

+54-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,54 @@
1-
util.subst = id
1+
-- Given a predicate `pred` and a proof of `pred1 <-> pred2`
2+
-- Prove that `pred <-> pred_` where `pred_` is `pred` with
3+
-- all occurences of `pred1` replaced with `pred2`
4+
5+
util.subst pred proof:(Proof predIff) = callWithPair
6+
(util.subst_preds proof) (iff2pair predIff) pred
7+
8+
-- Optimization
9+
util.subst_preds proof pred1 pred2 pred = ite (hasSubPred pred1 pred)
10+
(util.subst_preds_raw proof pred1 pred2) util.iff.refl pred
11+
12+
util.subst_preds_raw proof pred1 pred2 pred1 = proof
13+
util.subst_preds_raw proof pred1 pred2 pident:(Pident *) = util.iff.refl pident
14+
util.subst_preds_raw proof pred1 pred2 (Impl a b) = util.infer2
15+
(prove.taut
16+
(impl (synt.iff phi chi) (impl
17+
(synt.iff psi theta) (synt.iff
18+
(impl phi psi)
19+
(impl chi theta)))))
20+
(util.subst_preds proof pred1 pred2 a)
21+
(util.subst_preds proof pred1 pred2 b)
22+
util.subst_preds_raw proof pred1 pred2 (Pnot a) = util.infer
23+
(prove.taut
24+
(impl (synt.iff phi psi) (synt.iff
25+
(pnot phi)
26+
(pnot psi))))
27+
(util.subst_preds proof pred1 pred2 a)
28+
util.subst_preds_raw proof pred1 pred2 pelem:(Forall ident pred) = callWithPair
29+
(util.subst_preds_forall
30+
ident
31+
(util.subst_preds proof pred1 pred2 pred))
32+
(iff2pair (extract (util.subst_preds proof pred1 pred2 pred)))
33+
util.subst_preds_raw proof pred1 pred2 pelem:(Pelem * *) = util.iff.refl pelem
34+
35+
util.subst_preds_forall ident proof p1 p2 = util.infer2
36+
th.prop.iff.def.1
37+
(util.subst_preds_forall_impl
38+
ident
39+
(util.infer
40+
th.prop.iff.def.2
41+
proof)
42+
p1)
43+
(util.subst_preds_forall_impl
44+
ident
45+
(util.infer
46+
th.prop.iff.def.3
47+
proof)
48+
p2)
49+
50+
util.subst_preds_forall_impl ident proof pred = rule.uni.intr ident
51+
(util.tran
52+
(rule.uni.elim ident
53+
(util.impl.refl (forall ident pred)))
54+
proof)

0 commit comments

Comments
 (0)