to match on functions stuck in particular ways to perform rewrites by representing the context and goal using dependent functions and pairs Monday, March 3, 14
! Fin n _≟_ : {A : Set} (x y : A) ! Dec (x ≡ y) Context : Set Context = Σ Set (λ A ! A) tactic : Context ! Context tactic (Σ ℕ F , (n , i)) with F ≟ (λ n ! Fin (n + 0)) tactic (Σ ℕ .(λ m ! Fin (m + 0)) , n , i) | yes refl = (Σ ℕ Fin , (n , lemma n i)) tactic ((Σ ℕ F) , (n , i)) | no p = (Σ ℕ F , (n , i)) tactic (A , a) = (A , a) Monday, March 3, 14
language • Have already proven some meta-theory • Still a work in progress • I don’t see any major obstacles to modifying this to work with dependent types Monday, March 3, 14
• Part of meta-theory • β-equality via syntactic comparison of canonical terms • False just means terms are not equal now, not that further case analysis may make them equal later Monday, March 3, 14
the constructive [dependently typed] object language • x ≡ y • x ≢ y ≔ x ≡ y → ⊥ • Inconsistent to use definitional equality and simply lift it to propositional equality • danger lies in the unequal case Monday, March 3, 14
! Bool _≟_ : {A : Set} (x y : A) ! Dec (x ≡ y) x ≟ y with x == y ... | true = yes trustMe ... | false = no whatever where postulate whatever : _ Monday, March 3, 14
β-reducing, or partially evaluating, terms • Deciding propositional equality must address when it is safe to compare neutral terms • If it is unsafe to compare neutral terms, the comparison operation itself must be a neutral term! Monday, March 3, 14
result in a neutral term • Comparing neutral bodies of two functions can reduce by comparing “neutral” terms stuck on the variable bound by the function • Comparing two functions can partially evaluate based on bound neutral terms, but get stuck when comparing some inner “free” neutral term Monday, March 3, 14
Neutral (M : Mode) (Γ : Context) : Type ! Set data Value Γ where `tt : Value Γ `⊤ `true `false : Value Γ `Bool `zero : Value Γ `ℕ `suc : Value Γ `ℕ ! Value Γ `ℕ `λ : ∀{A B} ! Value (Γ , A % Sem) B ! Value Γ (A `! B) `neutral : ∀{A} M ! Neutral M Γ A ! Value Γ A data Neutral M Γ where `var : ∀{A} ! Var M Γ A ! Neutral M Γ A `if : ∀{C} ! Neutral M Γ `Bool ! Value Γ C ! Value Γ C ! Neutral M Γ C `fold : ∀{C} ! Neutral M Γ `ℕ ! Value Γ C ! Value Γ (C `! C) ! Neutral M Γ C _`==_ : ∀{A} ! Neutral M Γ A ! Value Γ A ! Neutral M Γ `Bool `surmise : ∀{A} ! Neutral M (Γ , A % Syn) `Bool ! Neutral M Γ `Bool _`$_ : ∀{A B} ! Neutral M Γ (A `! B) ! Value Γ A ! Neutral M Γ B Monday, March 3, 14
Neutral (M : Mode) (Γ : Context) : Type ! Set data Value Γ where `λ : ∀{A B} ! Value (Γ , A % Sem) B ! Value Γ (A `! B) `neutral : ∀{A} M ! Neutral M Γ A ! Value Γ A data Neutral M Γ where _`==_ : ∀{A} ! Neutral M Γ A ! Value Γ A ! Neutral M Γ `Bool `surmise : ∀{A} ! Neutral M (Γ , A % Syn) `Bool ! Neutral M Γ `Bool Monday, March 3, 14
Γ A ! Value Γ `Bool _⟦==ˢ⟧_ : ∀{Γ A} ! Neutral Syn Γ A ! Neutral Syn Γ A ! Value Γ `Bool `λ f₁ ⟦==⟧ `λ f₂ = ⟦surmise⟧ (⟦quote⟧ f₁ ⟦==⟧ ⟦quote⟧ f₂) `neutral Syn x₁ ⟦==⟧ `neutral Syn x₂ = x₁ ⟦==ˢ⟧ x₂ `neutral Sem x₁ ⟦==⟧ x₂ = `neutral Sem (x₁ `== x₂) x₁ ⟦==⟧ `neutral Sem x₂ = `neutral Sem (x₂ `== x₁) ⟦quote⟧ : ∀{Γ A B} ! Value (Γ , A % Sem) B ! Value (Γ , A % Syn) B ⟦surmise⟧ : ∀{Γ A} ! Value (Γ , A % Syn) `Bool ! Value Γ `Bool ⟦surmise⟧ `true = `true ⟦surmise⟧ `false = `false ⟦surmise⟧ (`neutral M x) = `neutral M (`surmise x) Monday, March 3, 14
terms • Due to presence of surmise, and used during partial evaluation • Comparing any two semantically closed terms reduces to a canonical term Monday, March 3, 14
(x y : Value Γ A) ! x ⟦≡⟧ y ! x ≡ y ⟦complete⟧ : ∀{Γ A} ! Closed Γ ! (x y : Value Γ A) ! x ≡ y ! x ⟦≡⟧ y _⟦≡⟧_ : ∀{Γ A} (x y : Value Γ A) ! Set x ⟦≡⟧ y = (x ⟦==⟧ y) ≡ `true Monday, March 3, 14
: Value Γ A) ! x ⟦≡⟧ x ⟦sym⟧ : ∀{Γ A} ! Closed Γ ! (x y : Value Γ A) ! x ⟦≡⟧ y ! y ⟦≡⟧ x ⟦trans⟧ : ∀{Γ A} ! Closed Γ ! (x y z : Value Γ A) ! x ⟦≡⟧ y ! y ⟦≡⟧ z ! x ⟦≡⟧ z Monday, March 3, 14
: Value Γ A ! Set) ! (x y : Value Γ A) ! x ⟦≡⟧ y ! P x ! P y ⟦cong⟧ : ∀{Γ A B} ! Closed Γ ! (f : Value Γ A ! Value Γ B) ! (x y : Value Γ A) ! x ⟦≡⟧ y ! f x ⟦≡⟧ f y ⟦dec⟧ : ∀{Γ A} ! Closed Γ ! (x y : Value Γ A) ! Dec (x ⟦≡⟧ y) Monday, March 3, 14
Neutral M Γ A → ⊥ ⟦sound2⟧ : ∀{Γ A} → Closed Γ → (x y : Value Γ A) → x ⟦≢⟧ y → x ≢ y ⟦complete2⟧ : ∀{Γ A} → Closed Γ → (x y : Value Γ A) → x ≢ y → x ⟦≢⟧ y _⟦≢⟧_ : ∀{Γ A} (x y : Value Γ A) ! Set x ⟦≢⟧ y = (x ⟦==⟧ y) ≡ `false Monday, March 3, 14