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
322fa8ee
Commit
322fa8ee
authored
4 years ago
by
gabrielhdt
Browse files
Options
Downloads
Patches
Plain Diff
Nat as primitive
parent
9eac043e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
paper/rat.lp
+26
-21
26 additions, 21 deletions
paper/rat.lp
with
26 additions
and
21 deletions
paper/rat.lp
+
26
−
21
View file @
322fa8ee
...
...
@@ -10,15 +10,8 @@ symbol not: Bool → Bool
set prefix 8 "¬" ≔ not
rule ε (¬ $x) ↪ ε $x → Π(z: Bool), ε z
// Declaration of a top type
constant symbol rat: Set
symbol eqrat: η (rat ~> rat ~> bool)
// Definition of a sub-type of ‘rat’
symbol nat_p: η (rat ~> bool) // Recogniser
definition nat ≔ psub nat_p
// Nat top type
constant symbol nat: Set
// Presburger arithmetics
constant symbol s: η (nat ~> nat)
constant symbol z: η nat
...
...
@@ -31,6 +24,24 @@ rule $n + z ↪ $n with $n + s $m ↪ s ($n + $m)
symbol nat_ind:
ε (∀ {nat ~> bool} (λp, (p z) ⇒ (∀ (λn, p n ⇒ p (s n))) ⇒ (∀ (λn, p n))))
// System T
symbol rec_nat: η nat → η nat → (η nat → η nat → η nat) → η nat
rule rec_nat z $t0 _ ↪ $t0
rule rec_nat (s $u) $t0 $ts ↪ $ts $u (rec_nat $u $t0 $ts)
definition mult a b ≔ rec_nat a z (λ_ r, b + r)
symbol times_nat: η (nat ~> nat ~> nat)
set infix left 5 "*" ≔ times_nat
rule z * _ ↪ z
with $n * (s $m) ↪ $n + ($n * $m)
with _ * z ↪ z // (times_z_left)
// Declaration of a top type
constant symbol frac: Set
symbol eqfrac: η (frac ~> frac ~> bool)
theorem z_plus_n_n: ε (∀ (λn, eqnat (z + n) n))
proof
assume n
...
...
@@ -40,12 +51,6 @@ proof
apply Hn
qed
symbol times_nat: η (nat ~> nat ~> nat)
set infix left 5 "*" ≔ times_nat
rule z * _ ↪ z
with $n * (s $m) ↪ $n + ($n * $m)
with _ * z ↪ z // (times_z_left)
// The following theorem allows to remove rule (times_z_left)
// but doing so would require to have eqnat transitivity, which requires some
// more work. So it is left for now.
...
...
@@ -70,15 +75,15 @@ proof
admit
// Building rationals from natural numbers
symbol
frac
: η (nat ~> nznat ~> ra
t
)
set infix left 6 "/" ≔
frac
rule eqra
t
($a / $b) ($c / $d) ↪ eqnat ($a * (fst $d)) ((fst $b) * $c)
symbol
div
: η (nat ~> nznat ~>
f
ra
c
)
set infix left 6 "/" ≔
div
rule eq
f
ra
c
($a / $b) ($c / $d) ↪ eqnat ($a * (fst $d)) ((fst $b) * $c)
// rule ε (nat_p ($n / pair $n _)) ↪ ε true
// Non linear rules break confluence
symbol times_ra
t
: η (ra
t
~> ra
t
~> ra
t
)
rule times_ra
t
($a / $b) ($c / $d)
symbol times_
f
ra
c
: η (
f
ra
c
~>
f
ra
c
~>
f
ra
c
)
rule times_
f
ra
c
($a / $b) ($c / $d)
↪ let denom ≔ fst $b * (fst $d) in
let prf ≔ nzprod $b $d in
($a * $c) / (pair denom prf)
...
...
@@ -87,7 +92,7 @@ rule times_rat ($a / $b) ($c / $d)
definition one_nz ≔ pair {nat} {nznat_p} (s z) (s_not_z z)
theorem right_cancel:
ε (∀ (λa, ∀ (λb, eqra
t
(times_ra
t
(a / b) (fst b / one_nz)) (a / one_nz))))
ε (∀ (λa, ∀ (λb, eq
f
ra
c
(times_
f
ra
c
(a / b) (fst b / one_nz)) (a / one_nz))))
proof
assume x y
simpl
...
...
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