Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
personoj
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
koizel
personoj
Commits
3f7dda1c
Commit
3f7dda1c
authored
5 years ago
by
gabrielhdt
Browse files
Options
Downloads
Patches
Plain Diff
more implicits on fst, moved nat
parent
0968aebf
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
encodings/cert_f.lp
+4
-4
4 additions, 4 deletions
encodings/cert_f.lp
sandbox/nat.lp
+15
-13
15 additions, 13 deletions
sandbox/nat.lp
sandbox/rat.lp
+35
-29
35 additions, 29 deletions
sandbox/rat.lp
with
54 additions
and
46 deletions
encodings/cert_f.lp
+
4
−
4
View file @
3f7dda1c
...
...
@@ -43,14 +43,14 @@ constant symbol Psub {T: Term uType}: (Term T ⇒ Term uProp) ⇒ Term uType
// Γ ⊢ M : { v : T | P }
// —————————————————————PROJl
// Γ ⊢ fst(M) : T
symbol fst {T: Univ Type}
(
P: Term T ⇒ Univ Prop
)
: Term (Psub P) ⇒ Term T
symbol fst {T: Univ Type}
{
P: Term T ⇒ Univ Prop
}
: Term (Psub P) ⇒ Term T
// Γ ⊢ M : { v : T | P }
// ——————————————————————————PROJr
// Γ ⊢ snd(M) : P[v ≔ fst(M)]
constant symbol snd {T: Univ Type} {P: Term T ⇒ Univ Prop}
(M: Term (Psub P)):
Term (P (fst
P
M))
Term (P (fst M))
// An inhabitant of a predicate subtype, that is, a pair of
// an element and the proof that it satisfies the predicate
...
...
@@ -60,7 +60,7 @@ constant symbol snd {T: Univ Type} {P: Term T ⇒ Univ Prop}
symbol pair {T: Univ Type} (P: Term T ⇒ Univ Prop) (M: Term T):
Term (P M) ⇒ Term (Psub P)
rule fst
_
(pair _ &M _) → &M
rule fst (pair _ &M _) → &M
// opair is a pair forgetting its snd argument
protected symbol opair (T: Univ Type) (P: Term T ⇒ Univ Prop) (M: Term T):
...
...
@@ -79,7 +79,7 @@ set declared "↑"
symbol ↑ {T: Term uType} (U: Term uType): Term (T ⊑ U) ⇒ Term T ⇒ Term U
rule ↑ {&T} &T _ &x → &x // Identity cast
// NOTE: a cast from a type [{x: A | P}] to type [A] is a [fst],
and ↑ {Psub {&T} &P} &T _ → fst &P
and ↑ {Psub {&T} &P} &T _ → fst
{&T} {
&P
}
// and a "downcast" is the pair constructor
set declared "↓"
...
...
This diff is collapsed.
Click to expand it.
adlib
/nat.lp
→
sandbox
/nat.lp
+
15
−
13
View file @
3f7dda1c
require open encodings.cert_f adlib.cert_f.booleans
prelude.cert_f.logic
constant symbol nat: Term uType
injective symbol succ: Term nat ⇒ Term nat
constant symbol zero: Term nat
require open
personoj.encodings.cert_f
personoj.adlib.bootstrap
personoj.prelude.logic
constant symbol Nat: Term uType
injective symbol succ: Term Nat ⇒ Term Nat
constant symbol zero: Term Nat
set builtin "0" ≔ zero
set builtin "+1" ≔ succ
symbol times : Term
n
at ⇒ Term
n
at ⇒ Term
n
at
symbol plus : Term
n
at ⇒ Term
n
at ⇒ Term
n
at
symbol times : Term
N
at ⇒ Term
N
at ⇒ Term
N
at
symbol plus : Term
N
at ⇒ Term
N
at ⇒ Term
N
at
set infix left 6 "+" ≔ plus
set infix left 7 "*" ≔ times
...
...
@@ -22,7 +24,7 @@ rule (succ &n) * &m → &n * &m + &m
and &n * (succ &m) → &n * &m + &n
and _ * 0 → 0
symbol prod_comm (x y: Term
n
at): Term (eq (times x y) (times y x))
symbol prod_comm (x y: Term
N
at): Term (eq (times x y) (times y x))
//
...
...
@@ -30,16 +32,16 @@ symbol prod_comm (x y: Term nat): Term (eq (times x y) (times y x))
//
definition not_zero ≔ neq 0
symbol prod_not_zero (x y: Term
n
at):
symbol prod_not_zero (x y: Term
N
at):
Term (not_zero x) ⇒ Term (not_zero y) ⇒ Term (not_zero (times x y))
definition
n
znat ≔ Psub not_zero
definition
N
znat ≔ Psub not_zero
// Constructor of nznat
definition nznat
c
(x: Term
n
at) (h: Term (not_zero x)) : Term
n
znat ≔
definition nznat (x: Term
N
at) (h: Term (not_zero x)) : Term
N
znat ≔
pair not_zero x h
symbol one_not_zero: Term (not_zero 1)
symbol induction (P: Term
n
at ⇒ Term bool):
symbol induction (P: Term
N
at ⇒ Term bool):
∀n, Term (P 0) ⇒ Term (P (n + 1)) ⇒ ∀m, Term (P m)
This diff is collapsed.
Click to expand it.
sandbox/rat.lp
+
35
−
29
View file @
3f7dda1c
require open encodings.cert_f adlib.cert_f.booleans
prelude.cert_f.logic
require adlib.cert_f.nat as N
require open
personoj.encodings.cert_f
personoj.adlib.bootstrap
personoj.prelude.logic
require personoj.sandbox.nat as N
set builtin "0" ≔ N.zero
set builtin "+1" ≔ N.succ
constant symbol rat : Univ Type
constant symbol zero : Term rat
constant symbol Rat : Term uType
constant symbol zero : Term Rat
symbol rat : Term N.Nat ⇒ Term N.Nznat ⇒ Term Rat
set infix 8 "/" ≔ rat
symbol frac : Term N.nat ⇒ Term N.nznat ⇒ Term rat
set infix 8 "/" ≔ frac
symbol times : Term Rat ⇒ Term Rat ⇒ Term Rat
symbol times : Term rat ⇒ Term rat ⇒ Term rat
type λx: Term N.Nznat, fst x
rule times (
f
ra
c
&a &b) (
f
ra
c
&c &d) →
let bv ≔ fst
N.not_zero
&b in
let dv ≔ fst
N.not_zero
&d in
f
ra
c
rule times (ra
t
&a &b) (ra
t
&c &d) →
let bv ≔ fst &b in
let dv ≔ fst &d in
ra
t
(N.times &a &c)
(N.nznat
c
(N.nznat
(N.times bv dv)
(N.prod_not_zero bv dv
(snd
N.not_zero
&b)
(snd
N.not_zero
&d)))
(snd &b)
(snd &d)))
symbol rateq : Term
r
at ⇒ Term
r
at ⇒
Univ Prop
symbol rateq : Term
R
at ⇒ Term
R
at ⇒
Term bool
rule rateq (&a / &b) (&c / &d) →
let nzval x ≔ fst
N.not_zero
x in
eq
(N.times &a (nzval &d)) (N.times (nzval &b) &c)
let nzval x ≔ fst x in
(N.times &a (nzval &d))
=
(N.times (nzval &b) &c)
definition onz : Term N.
n
znat ≔ N.nznat
c
1 N.one_not_zero
definition onz : Term N.
N
znat ≔ N.nznat 1 N.one_not_zero
theorem rrefl (a: Term N.
n
at) (b: Term N.
n
znat):
theorem rrefl (a: Term N.
N
at) (b: Term N.
N
znat):
Term (rateq (a / b) (a / b))
proof
assume a b
apply N.prod_comm a (fst
N.not_zero
b)
assume a b
apply N.prod_comm a (fst b)
qed
// theorem one_neutral (a: Term N.nat) (b: Term N.nznat):
// Term (rateq (times (a / b) (1 / onz)) (1 / onz))
// proof
// qed
type Term (N.nznat ⊑ N.nat)
type λ(b: Term N.nznat) (pr: Term (N.nznat ⊑ N.nat)),
@↑ N.nznat N.nat pr b
// FIXME explicitness required
theorem right_cancellation (a: Term N.nat) (b: Term N.nznat)
(pr: Term (N.nznat ⊑ N.nat)):
Term (rateq (times (a / b) ((@↑ N.nznat N.nat pr b) / onz)) (a / onz))
type Term (N.Nznat ⊑ N.Nat)
type λ(b: Term N.Nznat) (pr: Term (N.Nznat ⊑ N.Nat)),
↑ N.Nat pr b
theorem right_cancellation (a: Term N.Nat) (b: Term N.Nznat)
(pr: Term (N.Nznat ⊑ N.Nat)):
Term (rateq (times (a / b) ((↑ N.Nat pr b) / onz)) (a / onz))
proof
qed
// Should generate a TCC to provide [pr]
// theorem right_cancel (a b: Term N.Nat) ()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment