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
5e6ff53e
Commit
5e6ff53e
authored
4 years ago
by
gabrielhdt
Browse files
Options
Downloads
Patches
Plain Diff
Some notations updates
parent
ac71b194
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
encodings/subtype_poly.lp
+29
-29
29 additions, 29 deletions
encodings/subtype_poly.lp
paper/rat_poly.lp
+17
-5
17 additions, 5 deletions
paper/rat_poly.lp
with
46 additions
and
34 deletions
encodings/subtype_poly.lp
+
29
−
29
View file @
5e6ff53e
...
...
@@ -8,10 +8,10 @@ require open personoj.encodings.prenex
set declared "μ"
set declared "μ₀"
set declared "π"
set declared "
↑
"
set declared "
⇑
"
set declared "↓"
//
Maximal super
type
//
Top
type
symbol μ: Set → Set
rule μ (psub {$T} _) ↪ μ $T
with μ ($T ~> $U) ↪ $T ~> (μ $U)
...
...
@@ -20,52 +20,52 @@ with μ (arrd $b) ↪ arrd (λx, μ ($b x))
with μ (μ $T) ↪ μ $T // FIXME: can be proved
symbol π (T: Set): η (μ T) → Bool
rule π ($t ~> $u) ↪ λx: η $t → η (μ $u), ∀ (λy, π $u (x y))
with π (tuple_t $t $u)
↪ λx: η (tuple_t (μ $t) (μ $u)), π $t (p1 x) ∧ (λ_, π $u (p2 x))
with π (arrd $b)
↪ λx: η (arrd (λx, μ ($b x))), ∀ (λy, π ($b y) (x y))
// Casting from/to maximal supertype
symbol
max
cast {t: Set}: η t → η (μ t)
symbol
top
cast {t: Set}: η t → η (μ t)
symbol downcast {t: Set} (x: η (μ t)): ε (π t x) → η t
definition
↑
{t} ≔
max
cast {t}
definition
⇑
{t} ≔
top
cast {t}
definition ↓ {t} ≔ downcast {t}
symbol
_
downcast {t: Set}: η (μ t) → η t
rule downcast {$t} $x _ ↪
_
downcast {$t} $x
symbol downcast
_
{t: Set}: η (μ t) → η t
// Proof irrelevant downcast
rule downcast {$t} $x _ ↪ downcast
_
{$t} $x
rule π ($t ~> $u) ↪ λx: η $t → η (μ $u), ∀ (λy, π $u (x y))
with π (tuple_t $t $u)
↪ λx: η (tuple_t (μ $t) (μ $u)), π $t (p1 x) ∧ (λ_, π $u (p2 x))
with π (psub {$t} $a)
rule π (psub {$t} $a)
↪ λx: η (μ $t), (π $t x) ∧ (λy: ε (π $t x), $a (↓ x y))
with π (arrd $b)
↪ λx: η (arrd (λx, μ ($b x))), ∀ (λy, π ($b y) (x y))
/// A term ‘x’ that has been cast up still validates the properties to be of its
/// former type.
symbol cstr_
max
cast_idem: ε (∀B (λt, ∀ {t} (λx, π t (
max
cast x))))
symbol cstr_
top
cast_idem: ε (∀B (λt, ∀ {t} (λx, π t (
top
cast x))))
// or as a rewrite-rule:
// rule ε (π _ (
max
cast _)) ↪ ε true
// rule ε (π _ (
top
cast _)) ↪ ε true
private constant symbol
max
_eq: Set → Set → Bool
set infix 6 "≃" ≔
max
_eq
private constant symbol
top
_eq: Set → Set → Bool
set infix 6 "≃" ≔
top
_eq
// fr and to must be supertypes
symbol eqcast {fr: Set} {to: Set}: ε (fr ≃ to) → η (μ fr) → η (μ to)
protected symbol
_
eqcast {fr: Set} {to: Set}: η (μ fr) → η (μ to)
rule eqcast {$fr} {$to} _ $e ↪
_
eqcast {$fr} {$to} $e
rule
_
eqcast {$t} {$t} $e ↪ $e
protected symbol eqcast
_
{fr: Set} {to: Set}: η (μ fr) → η (μ to)
rule eqcast {$fr} {$to} _ $e ↪ eqcast
_
{$fr} {$to} $e
rule eqcast
_
{$t} {$t} $e ↪ $e
definition compatible (t u: Set) ≔ μ t ≃ μ u
set infix 6 "~" ≔ compatible
// The one true cast
symbol cast {fr_t: Set} (to_t: Set) (comp: ε (fr_t ~ to_t)) (m: η fr_t):
ε (π to_t (eqcast comp (
max
cast m))) → η to_t
ε (π to_t (eqcast comp (
top
cast m))) → η to_t
/// Proof irrelevance
protected symbol
_
cast {fr_t: Set} (to_t: Set): η fr_t → η to_t
rule cast {$f_t} $t_t _ $x _ ↪
_
cast {$f_t} $t_t $x
rule
_
cast {$t} $t $x ↪ $x // REVIEW: critical pairs?
rule
_
cast {$fr_t} $to_t $e
↪
_
downcast {$to_t} (
_
eqcast {$fr_t} {$to_t} (
↑
{$fr_t} $e))
// REVIEW: we can directly rewrite cast to _downcast and
max
cast, dropping
protected symbol cast
_
{fr_t: Set} (to_t: Set): η fr_t → η to_t
rule cast {$f_t} $t_t _ $x _ ↪ cast
_
{$f_t} $t_t $x
rule cast
_
{$t} $t $x ↪ $x // REVIEW: critical pairs?
rule cast
_
{$fr_t} $to_t $e
↪ downcast
_
{$to_t} (eqcast
_
{$fr_t} {$to_t} (
⇑
{$fr_t} $e))
// REVIEW: we can directly rewrite cast to _downcast and
top
cast, dropping
// _cast
theorem comp_same_cstr_cast
...
...
@@ -75,11 +75,11 @@ theorem comp_same_cstr_cast
(π fr)
(λx, π to (eqcast comp x))))
(x: η fr)
: ε (π to (eqcast comp (
max
cast x)))
: ε (π to (eqcast comp (
top
cast x)))
proof
assume fr to comp eq_cstr x
refine eq_cstr (λf, f (
max
cast x)) _
refine cstr_
max
cast_idem fr x
refine eq_cstr (λf, f (
top
cast x)) _
refine cstr_
top
cast_idem fr x
qed
rule ε ($t ≃ $t) ↪ ε true
...
...
This diff is collapsed.
Click to expand it.
paper/rat_poly.lp
+
17
−
5
View file @
5e6ff53e
...
...
@@ -9,8 +9,8 @@ set infix right 2 "⇒" ≔ imp
constant symbol rat: Set
rule π rat ↪ λ_, true
rule μ rat ↪ rat
rule
max
cast {rat} $x ↪ $x
rule
_
downcast {rat} $e ↪ $e
rule
top
cast {rat} $x ↪ $x
rule downcast
_
{rat} $e ↪ $e
constant symbol z: η rat
...
...
@@ -33,7 +33,7 @@ constant symbol s_not_z:
ε (∀ {nat} (λx, ¬ (z = (cast rat (λx, x) (s x) (λx, x)))))
rule ε (z = z) ↪ ε true
rule ε ((
_
cast rat (s $n)) = (
_
cast rat (s $m)))
rule ε ((cast
_
rat (s $n)) = (cast
_
rat (s $m)))
↪ ε ((cast rat (λx, x) $n (λx, x)) = (cast rat (λx, x) $m (λx, x)))
theorem plus_closed_nat:
...
...
@@ -52,8 +52,8 @@ proof
admit
set flag "print_implicits" on
rule (
_
cast {nat} rat $n) + z ↪ cast rat (λx, x) $n (λx, x)
with (
_
cast {nat} rat $n) + (
_
cast rat (s $m))
rule (cast
_
{nat} rat $n) + z ↪ cast rat (λx, x) $n (λx, x)
with (cast
_
{nat} rat $n) + (cast
_
rat (s $m))
↪ cast {nat} rat (λx, x)
(s (cast {rat} nat (λx, x)
((cast {nat} rat (λx, x) $n (λx, x))
...
...
@@ -146,3 +146,15 @@ admit
// (times (cast {nznat} rat (λx, x) $b (λx, x))
// (cast {nznat} rat (λx, x) $d (λx, x)))
// (tcc3 $b $d))
theorem tcc6: ε (and true (λ_, nat_p z))
proof
admit
definition one ≔ s (cast nat (λx, x) z tcc6)
// FIXME: same as above
// theorem tcc7: ε (and true
// (λ_, and (nat_p (cast rat (λx, x) one (λx, x)))
// (λ_, nznat_p one)) )
// proof
// admit
// definition one_nz ≔ cast nznat (λx, x) one tcc7
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