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