Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rectification Campaign II: Restrictions, etc. #230

Merged
merged 64 commits into from
Aug 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
64c89c8
not sure if needed
jonsterling Aug 14, 2018
213e08c
fix another potentially subtle bug
jonsterling Aug 14, 2018
adb8022
first pass at deleting box modality
jonsterling Aug 14, 2018
cabae7d
add files that I forgot to check in (Kind.mli, Lvl.mli)
jonsterling Aug 14, 2018
19c5abc
remove locks, tick constant, etc.
jonsterling Aug 14, 2018
e205cba
delete bad idea, push_restriction
jonsterling Aug 14, 2018
0c0e819
adding explicit support for definitions, don't use "singleton types" …
jonsterling Aug 14, 2018
ebdfc1c
dead code
jonsterling Aug 14, 2018
26672d1
fancy typechecking algorithm with judgmental restriction
jonsterling Aug 14, 2018
b60085e
start keeping track of which of Evan's brutal examples work
jonsterling Aug 14, 2018
18a56fb
add evan's brutal stuff to the makefile :)
jonsterling Aug 14, 2018
f4df7db
do not try to support subtyping between a restriction type & non-rest…
jonsterling Aug 14, 2018
1ec2ce6
Revert "do not try to support subtyping between a restriction type & …
jonsterling Aug 14, 2018
fcc741e
start adding more info to tactic input (just adding record for now)
jonsterling Aug 14, 2018
d4930fa
minor code cleanup
jonsterling Aug 14, 2018
8d930fb
code simplification
jonsterling Aug 14, 2018
f44b4c5
potential switcharoo ???
jonsterling Aug 14, 2018
3d05532
trying to get less owned by things being backwards ??
jonsterling Aug 14, 2018
375dd34
pretty printing for debugging
jonsterling Aug 15, 2018
46943e7
more partial fixing of resolution bugs
jonsterling Aug 15, 2018
f30b783
more debuggable clause lookup
jonsterling Aug 15, 2018
11ff3c6
debugging
jonsterling Aug 15, 2018
7337f54
turn off unused-variable error (MAKES DEBUGGING IMPOSSIBLE)
jonsterling Aug 15, 2018
af5f42b
some reasonable changes
jonsterling Aug 15, 2018
fa60b79
temporary stop checking boundaries of elim clauses until I rectify
jonsterling Aug 15, 2018
b56a4b6
think I may have fixed typechecking of elim
jonsterling Aug 15, 2018
31c81bf
minor fix
jonsterling Aug 15, 2018
943a280
first attempt to refine elim clause boundaries again
jonsterling Aug 15, 2018
08f0745
tentative fix to evan's other example
jonsterling Aug 15, 2018
0ffabba
remove comment
jonsterling Aug 15, 2018
259a407
fix another bug found by @ecavallo (keep 'em coming!)
jonsterling Aug 15, 2018
d414fe0
reformat some code to use Jon Sterling Thought
jonsterling Aug 15, 2018
be824ce
progress toward super advanced restriction-oriented elaborator
jonsterling Aug 15, 2018
f253007
explain Evan's other example
jonsterling Aug 15, 2018
37abe04
rename utility function
jonsterling Aug 15, 2018
d842fbb
don't let the user type in a restriction type
jonsterling Aug 15, 2018
bf0a3bc
tentative fancy printing of goals with restriction
jonsterling Aug 15, 2018
9bf4359
fix generation of tactics for missing cases in elim
jonsterling Aug 15, 2018
306d043
comment
jonsterling Aug 15, 2018
96b60e3
smart constructor to decrease some term annotation clutter
jonsterling Aug 15, 2018
b023579
minor cleanup
jonsterling Aug 15, 2018
bb9f634
better version of typechecking algorithm
jonsterling Aug 15, 2018
6bbf7de
NO MORE MANUAL ETA EXPANSION!!!!
jonsterling Aug 15, 2018
01bda5c
cleanup examples
jonsterling Aug 15, 2018
0325751
adding a basic auto tactic
jonsterling Aug 15, 2018
a09e864
oops, remove quit statement
jonsterling Aug 15, 2018
aa17701
one more
jonsterling Aug 15, 2018
f199ded
exercise eta and auto a little more
jonsterling Aug 16, 2018
69b75be
Close #212; close #237
jonsterling Aug 16, 2018
84d3375
cleanup refiner interface a little
jonsterling Aug 16, 2018
63b60ad
factor sigma-intro out of elaborator and into refiner
jonsterling Aug 16, 2018
3d24751
automatically do sigma-intro in auto
jonsterling Aug 16, 2018
88e3df2
formatting
jonsterling Aug 16, 2018
2cd0212
Elaborator: don't invoke normalizer to apply frames to terms
jonsterling Aug 16, 2018
cdf0efe
add more stuff to torus example, note bug #240
jonsterling Aug 17, 2018
69bf48d
Resolve #240
jonsterling Aug 17, 2018
b99bac4
add "normalize" command (/cc @mortberg)
jonsterling Aug 17, 2018
edced45
finish up proof of torus ~ s1 × s1
jonsterling Aug 17, 2018
ee3804e
add links to other versions of the proof
jonsterling Aug 17, 2018
4893d69
resolve #238
jonsterling Aug 17, 2018
8daafc8
removing bad.red from source control
jonsterling Aug 17, 2018
d82643e
Oops, my fix didn't work. Just disable strict composition for now.
jonsterling Aug 17, 2018
40085ba
add a clarifying comment
jonsterling Aug 17, 2018
7df8692
remove bad.red from makefile
jonsterling Aug 17, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 24 additions & 21 deletions J.red
Original file line number Diff line number Diff line change
Expand Up @@ -6,44 +6,47 @@ let J
(x : A) (p : Path _ a x)
: C x p
=
let ty : dim → type = λ i →
let h : dim → A = λ j →
comp 0 j a [
| i=0 ⇒ λ _ → a
| i=1 ⇒ λ k → p k
]
in
C (h 1) (λ k → h k)
let ty : dim → type =
λ i →
let h : dim → A =
λ j →
comp 0 j a [
| i=0 ⇒ auto
| i=1 ⇒ p
]
in
C (h 1) h
in
coe 0 1 d in ty

let J/eq
(A : type) (a : A)
(C : (x : A) (p : Path A a x) → type) (d : C a (λ _ → a))
: Path (C a _) (J _ _ C d _ (λ _ → a)) d
(C : (x : A) (p : Path A a x) → type) (d : C a auto)
: Path (C a auto) (J _ _ C d _ (λ _ → a)) d
=
let square : dim → dim → A =
λ i j →
comp 0 j a [
| i=0 ⇒ λ _ → a
| i=1 ⇒ λ _ → a
| i=0 ⇒ auto
| i=1 ⇒ auto
]
in
λ k →
comp 0 1 d in λ i →
let aux : dim → A =
λ j →
comp 0 j a [
| k=0 ⇒ λ l → square i l
| k=1 ⇒ λ _ → a
| i=0 ⇒ λ _ → a
| i=1 ⇒ λ _ → a
| k=0 ⇒ square i
| k=1 ⇒ auto
| i=0 ⇒ auto
| i=1 ⇒ auto
]
in
C (aux 1) (λ l → aux l)
C (aux 1) aux
with
| k=0 ⇒ λ i →
coe 0 i d in λ j →
C (square j 1) (λ k → square j k)
| k=1 ⇒ λ _ → d
| k=0 ⇒
λ i →
coe 0 i d in λ j →
C (square j 1) (square j)
| k=1 ⇒ auto
end
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ and [cubicaltt](https://github.com/mortberg/cubicaltt).
supported) based on the [work of Evan Cavallo and Bob
Harper](https://arxiv.org/abs/1801.01568)

- experimental support for Fitch-style modal guarded recursion: □,
- experimental support for Fitch-style modal guarded recursion: ▷


Features we intend to add in the near future:
Expand Down
4 changes: 2 additions & 2 deletions bool.red
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ let not∘not (x : bool) : _ =

let not∘not/id/pt (x : bool) : Path _ (not∘not x) x =
elim x [
| tt ⇒ λ _ → tt
| ff ⇒ λ _ → ff
| tt ⇒ auto
| ff ⇒ auto
]
42 changes: 14 additions & 28 deletions connection.red
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import path

let singleton (A : type) (M : A) : type pre =
restrict A [
| 0=0 ⇒ M
]

let connection/or
(A : type)
(p : dim → A)
Expand All @@ -22,27 +17,18 @@ let connection/or
let face : dim → dim → A =
λ l k →
comp 0 l (p k) [
| k=1 ⇒ λ _ → p 1
| k=0 ⇒ λ m → p m
| k=1 ⇒ auto
| k=0 ⇒ p
]
in
comp 1 0 (p 1) [
| i=0 ⇒ λ k → face j k
| i=1 ⇒ λ k → face 1 k
| j=0 ⇒ λ k → face i k
| j=1 ⇒ λ k → face 1 k
| i=j ⇒ λ k → face i k
| i=0 ⇒ face j
| i=1 ⇒ face 1
| j=0 ⇒ face i
| j=1 ⇒ face 1
| i=j ⇒ face i
]

; an example of using the singleton type to establish an exact equality
let connection/or/diagonal
(A : type)
(p : dim → A)
: singleton _ p
=
λ i →
connection/or _ p i i

let connection/and
(A : type)
(p : dim → A)
Expand All @@ -57,16 +43,16 @@ let connection/and
let face : dim → dim → A =
λ l k →
comp 1 l (p k) [
| k=0 ⇒ λ _ → p 0
| k=1 ⇒ λ m → p m
| k=0 ⇒ auto
| k=1 ⇒ p
]
in
comp 0 1 (p 0) [
| i=0 ⇒ λ k → face 0 k
| i=1 ⇒ λ k → face j k
| j=0 ⇒ λ k → face 0 k
| j=1 ⇒ λ k → face i k
| i=j ⇒ λ k → face i k
| i=0 ⇒ face 0
| i=1 ⇒ face j
| j=0 ⇒ face 0
| j=1 ⇒ face i
| i=j ⇒ face i
]


5 changes: 5 additions & 0 deletions equivalence.red
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,8 @@ let IsEquiv (A, B : type) (f : A → B) : type =

let Equiv (A, B : type) : type =
(f : A → B) × IsEquiv _ _ f

let UA (A,B : type) (E : Equiv A B) : Path^1 type A B =
λ i →
`(V i A B E)

5 changes: 2 additions & 3 deletions hedberg-wip.red
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ let or/elim
(m0 : A → C)
(m1 : B → C)
: C =
sg/elim bool (λ b → elim b [tt ⇒ A | ff ⇒ B]) (λ _ _ → C) t
sg/elim bool _ (λ _ _ → C) t
(λ b →
elim b in (λ b → (elim b in (λ _ → type) [tt ⇒ A | ff ⇒ B]) → C)
[tt ⇒ m0 | ff ⇒ m1])
elim b [tt ⇒ m0 | ff ⇒ m1])

let neg (A : type) : type =
A → void
Expand Down
14 changes: 7 additions & 7 deletions int.red
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,23 @@ let isuc (x : int) : int =

let pred-isuc (n : int) : Path int (pred (isuc n)) n =
elim n [
| pos n ⇒ λ _ → pos n
| pos n ⇒ auto
| negsuc n ⇒
elim n [
| zero ⇒ λ _ → negsuc zero
| suc n ⇒ λ _ → negsuc (suc n)
| zero ⇒ auto
| suc n ⇒ auto
]
]

let isuc-pred (n : int) : Path int (isuc (pred n)) n =
elim n [
| pos n ⇒
elim n [
| zero ⇒ λ _ → pos zero
| suc n' ⇒ λ _ → pos (suc n')
| zero ⇒ auto
| suc n' ⇒ auto
]
| negsuc n ⇒ λ _ → negsuc n
| negsuc n ⇒ auto
]

let isuc-equiv : Equiv int int =
Iso/Equiv _ _ < isuc, < pred, < isuc-pred, pred-isuc > > >
Iso/Equiv _ _ <isuc, <pred, <isuc-pred, pred-isuc>>>
12 changes: 6 additions & 6 deletions invariance.red
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ let shannon (A : type) (f : bool → A) : bool → A =


let shannon/path (A : type) (f : bool → A) : Path _ f (shannon A f) =
funext bool _ _ _
funext _ _ f (shannon A f)
(λ b →
elim b in λ x → Path _ (f x) (shannon A f x) [
| tt ⇒ λ _ → f tt
| ff ⇒ λ _ → f ff
elim b [
| tt ⇒ auto
| ff ⇒ auto
])

let fun-to-pair-is-equiv (A : type) : IsEquiv^1 (_ → _) _ (fun-to-pair A) =
Expand All @@ -45,8 +45,8 @@ let fun-to-pair-is-equiv (A : type) : IsEquiv^1 (_ → _) _ (fun-to-pair A) =
>)
in λ j →
[i] (f : bool → A) × Path (A × A) <f tt, f ff> p [
| i=0 ⇒ < shannon/path A (fib.0) j, fib.1 >
| i=1 ⇒ < pair-to-fun A p, λ _ → p >
| i=0 ⇒ <shannon/path A (fib.0) j, fib.1>
| i=1 ⇒ <pair-to-fun A p, auto>
]
>

Expand Down
22 changes: 11 additions & 11 deletions isotoequiv.red
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ let Iso/fiber-is-prop
let sq : (_ : Fiber _ _ (I.0) b) (i, j : dim) → A =
λ fib i j →
comp 0 j (g (fib.1 i)) [
| i=0 ⇒ λ k → β (fib.0) k
| i=1 ⇒ λ _ → g b
| i=0 ⇒ β (fib.0)
| i=1 ⇒ auto
]
in
λ fib0 fib1 →
Expand All @@ -36,21 +36,21 @@ let Iso/fiber-is-prop
]
in
λ i →
< sq2 i 0
< auto
, λ j →
let aux : A =
comp 1 0 (sq2 i j) [
| i=0 ⇒ λ k → sq fib0 j k
| i=1 ⇒ λ k → sq fib1 j k
| j=0 ⇒ λ k → β (sq2 i 0) k
| j=1 ⇒ λ _ → g b
| i=0 ⇒ sq fib0 j
| i=1 ⇒ sq fib1 j
| j=0 ⇒ β (sq2 i 0)
| j=1 ⇒ auto
]
in
comp 0 1 (f aux) [
| i=0 ⇒ λ k → α (fib0.1 j) k
| i=1 ⇒ λ k → α (fib1.1 j) k
| j=0 ⇒ λ k → α (f (sq2 i 0)) k
| j=1 ⇒ λ k → α b k
| i=0 ⇒ α (fib0.1 j)
| i=1 ⇒ α (fib1.1 j)
| j=0 ⇒ α (f (sq2 i 0))
| j=1 ⇒ α b
]
>

Expand Down
54 changes: 0 additions & 54 deletions modal.red
Original file line number Diff line number Diff line change
Expand Up @@ -30,57 +30,3 @@ let stream/tl (xs : stream) : ✓ → stream =
let tts : _ =
fix xs : stream in
stream/cons tt xs


; To eliminate a box, write 'b !'; this elaborates to the core term `(open b).
let bool/constant (x : bool) : (b : □ bool) × Path _ x (b !) =
elim x [
| tt ⇒ < shut tt, λ _ → tt >
| ff ⇒ < shut ff, λ _ → ff >
]

let sequence : type = □ stream


let Next (A : type) (x : A) ✓ : A =
x

let sequence/cons (x : bool) (xs : sequence) : sequence =
shut
stream/cons
(bool/constant x .0 !)
(Next stream (xs !))
; this is suspicious: we use this Next in order to essentially
; weaken away the tick that we will not use, in order to get the right number
; of locks deleted. But this is proof-theoretically very strange.

; The proper solution to the problem above is to bind lock names in the syntax and in the context,
; analogous to tick names. This will make the calculus more baroque, but it will enable a
; deterministic version of the 'open' rule. The source term for the above would then be:
;
; λ α → stream/cons (bool/constant x .0 α) (λ β → xs α)
;
; Above, α is a lock name and β is a tick name; opening with the lock α
; would *delete* the tick β from the context (thinking backward), which is
; a tick weakening. the example would typecheck because there is no need for
; β in xs.
;
; For reference, the core-language term would look like the following:
;
; (shut [α]
; (stream/cons
; (open α (car (bool/constant x)))
; (next [β] (open α xs))))



let sequence/hd (xs : sequence) : bool =
stream/hd (xs !)

let sequence/tl (xs : sequence) : sequence =
shut
stream/tl (xs !) ∙


let law/k (A,B : type) (f : □ (A → B)) (x : □ A) : □ B =
shut f ! (x !)
10 changes: 5 additions & 5 deletions nat.red
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ let nat-pred (x : nat) : nat =


let nat-pred/suc (x : nat) : Path nat x (nat-pred (suc x)) =
λ _ → x
auto

let plus : nat → nat → nat =
λ m n →
Expand All @@ -23,23 +23,23 @@ let plus : nat → nat → nat =
]

let plus/unit/l (n : nat) : Path nat (plus zero n) n =
λ i → n
auto

let plus/unit/r (n : nat) : Path nat (plus n zero) n =
elim n [
| zero ⇒ λ _ → zero
| zero ⇒ auto
| suc (n ⇒ path/n) ⇒ λ i → suc (path/n i)
]

let plus/assoc (n : nat) : (m, o : nat) → Path nat (plus n (plus m o)) (plus (plus n m) o) =
elim n [
| zero ⇒ λ m o i → plus m o
| zero ⇒ auto
| suc (n ⇒ plus/assoc/n) ⇒ λ m o i → suc (plus/assoc/n m o i)
]

let plus/suc/r (n : nat) : (m : nat) → Path nat (plus n (suc m)) (suc (plus n m)) =
elim n [
| zero ⇒ λ m _ → suc m
| zero ⇒ auto
| suc (n ⇒ plus/n/suc/r) ⇒ λ m i → suc (plus/n/suc/r m i)
]

Expand Down
Loading