Skip to content

Instantly share code, notes, and snippets.

@brendanzab
Last active April 29, 2021 06:48
Show Gist options
  • Select an option

  • Save brendanzab/68f3878cb1b777dfc80a88af63f60bc1 to your computer and use it in GitHub Desktop.

Select an option

Save brendanzab/68f3878cb1b777dfc80a88af63f60bc1 to your computer and use it in GitHub Desktop.

Weird type theory diagrams

I always get confused about terms, types, expressions, etc. in full spectrum dependent types… so toying around with these :sparkles: very informal :sparkles: Venn diagram thingies.

Note: Don't take this super seriously or authoritatively, it's more me trying to figure things out, and I'm very sloppy at this stuff!

Syntax

term ::=
  | var                        % variable
  | Type                       % universe               (type)
  | Π (x : term). term         % function former        (type)
  | λ (x : term). term         % function introduction  (expression)
  | term term                  % function elimination   (expression)
  | ...
╭──────────────────────────────────────────────────────────────────────╮
│                           Term                                       │
│                                                                      │
│      ╭──────────────╮                                                │
│      │   Variable   │                                                │
│      ╰──────────────╯                                                │
│  ╭────────────────────────╮   ╭───────────────────────────────────╮  │
│  │       Expression       │   │               Type                │  │
│  │  ╭─────────┬────────╮  │   │  ╭────────────╮   ╭────────────╮  │  │
│  │  │  Intro  │  Elim  │  │ ∈ │  │   Former   │ ∈ │  Universe  │  │  │
│  │  ╰─────────┴────────╯  │   │  ╰────────────╯   ╰────────────╯  │  │
│  ╰────────────────────────╯   ╰───────────────────────────────────╯  │
╰──────────────────────────────────────────────────────────────────────╯

Semantics

value ::=
  | stuck
  | Type                            % universe               (type)
  | Π (x : value). ⟨value*, term⟩   % function former        (type)
  | λ (x : value). ⟨value*, term⟩   % function introduction  (expression)
  | ...

stuck ::=
  | var                             % variable
  | stuck term                      % function elimination   (expression)
  | ...
╭────────────────────────────────────────────────────────────────────────────────────╮
│                                    Value                                           │
│                                                                                    │
│  ╭────────────────────╮                                                            │
│  │   Stuck (Neutral)  │                                                            │
│  │                    │                                                            │
│  │   ╭────────────╮   │                                                            │
│  │   │  Variable  │   │                                                            │
│  │   ╰────────────╯   │                                                            │
│  │  ╭───────────────────────────────────╮   ╭───────────────────────────────────╮  │
│  │  │            Expression             │   │                 Type              │  │
│  │  │  ╭──────────╮   ╷  ╭────────────╮ │   │  ╭────────────╮   ╭────────────╮  │  │
│  │  │  │   Elim   │   ╎  │   Intro    │ │ ∈ │  │   Former   │ ∈ │  Universe  │  │  │
│  │  │  ╰──────────╯   ╎  ╰────────────╯ │   │  ╰────────────╯   ╰────────────╯  │  │
│  │  ╰───────────────────────────────────╯   ╰───────────────────────────────────╯  │
│  ╰────────────────────╯                                                            │
╰────────────────────────────────────────────────────────────────────────────────────╯

Entity/Object

               Entity/Object
╭─────────────────────┬─────────────────────────────────────╮
│                     │                                     │
│       Definition    ∈      Declaration                    │
│                     │                                     │
│  ╭────────────────────────────────────────╮               │
│  │          ╭───────────────╮             │               │  ∈  Context/Environment
│  │ Abstract │   Variable    │   Opaque    │               │
│  │          ╰───────────────╯             │   ╭────────╮  │
│  ├────────────────────────────────────────┤ ∈ │  Type  │  │
│  │          ╭───────────────╮             │   ╰────────╯  │
│  │ Concrete │     Value     │ Transparent │               │
│  │          ╰───────────────╯             │               │
│  ╰────────────────────────────────────────╯               │
╰─────────────────────┴─────────────────────────────────────╯
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment