reasoning about computational systems using abella
play

Reasoning about Computational Systems using Abella Kaustuv Chaudhuri - PowerPoint PPT Presentation

http://abella-prover.org Reasoning about Computational Systems using Abella Kaustuv Chaudhuri 1 Gopalan Nadathur 2 1 Inria & LIX/cole polytechnique, France 2 Department of Computer Science and Engineering University of Minnesota,


  1. Reasoning About Defined Atoms To reason about hypothesis p M1 · · · Mn : 1 Find every way to unify p M1 · · · Mn with some head; 2 Separately reason about each corresponding instance of the body as a new hypothesis. Generates one premise (subgoal) per unification solution. Observe the analogy with equality assumptions! 32

  2. Define plus : nat -> nat -> nat -> prop by plus z N N ; plus (s M) N (s K) := plus M N K. Theorem plus_s : forall M N K, plus M N (s K) -> (exists J, M = s J) \/ (exists J, N = s J). Reasoning About Defined Atoms: Example Given hypothesis: plus M N (s K) : 1 Generate one subgoal for the first clause and unifier [ z / M , s K / N ] ; 2 Another subgoal for the second clause and unifier [ s M’ / M ] 33

  3. 2.3 – case and unfold The case and unfold Tactics 34

  4. p := p -> false. Define p : prop by Consistency of Relational Definitions • Relational definitions are given a fixed point interpretation. • That is, every defined atom is considered to be equivalent to the disjunction of its unfolded forms. • Such an equivalence can introduce inconsistencies. • Abella’s stratification condition guarantees consistency. 35

  5. 2.4 – Stratification Stratification 36

  6. Define is_nat1 : nat -> prop by is_nat1 z ; is_nat1 (s N) := is_nat1 N. Define is_nat2 : nat -> prop by is_nat2 z ; is_nat2 (s N) := is_nat2 N. forall x, is_nat1 x -> is_nat2 x. The Expressivity of case and unfold Consider • With case and unfold , we cannot prove: • Abella actually interprets fixed points as least fixed points. • This in turn allows us to perform induction on such definitions. 37

  7. forall X1 ... Xn, F1 -> ... -> Fk -> ... -> G induction on k. forall X1 ... Xn, F1 -> ... -> Fk * -> ... -> G forall X1 ... Xn, F1 -> ... -> Fk @ -> ... -> G The induction tactic Given a goal where Fk is a defined atom, the invocation 1 Adds an inductive hypothesis ( IH ): 2 Then changes the goal to: 38

  8. Inductive Annotations Meaning of F* F has resulted from at least one application of case to an as- sumption of the form F’@ . • These annotations are only maintained on defined atoms. • Applying case to F@ changes the annotation to * for the resulting bodies in every subgoal. • The * annotation percolates to: • Both operands of /\ and \/ ; • Only the right operand of -> ; and • The bodies of forall and exists . 39

  9. 2.5 – Natural Numbers Natural Number Induction 40

  10. 2.6 – Lists Lists of Natural Numbers 41

  11. 2.7 – Nested and Mutual Induction Nested and Mutual Induction 42

  12. The Reasoning Logic G Outline: 1 Ordinary Intuitionistic Logic 2 Equality 3 Fixed Point Definitions 4 Induction • Inductive data: lists • Kinds of induction: simple, mutual, nested 5 Higher-Order Abstract Syntax • Example: subject reduction for STLC 43

  13. The Reasoning Logic G Outline: 1 Ordinary Intuitionistic Logic 2 Equality 3 Fixed Point Definitions 4 Induction • Inductive data: lists • Kinds of induction: simple, mutual, nested 5 Higher-Order Abstract Syntax • Example: subject reduction for STLC 44

  14. Principles of Abstract Syntax [Miller 2015] 1 The names of bound variables should be treated as the same kind of fiction as we treat white space: they are artifacts of how we write expressions and have no semantic content. 2 There is “one binder to ring them all.” 3 There is no such thing as a free variable. – cf. Alan Perlis’ epigram #47 4 Bindings have mobility and the equality theory of expressions must support such mobility […]. 45

  15. Higher-Order Abstract Syntax Also known as: λ -Tree Syntax • Binding constructs in syntax are represented with term constructors of higher-order types. • The normal forms of the representation are in bijection with the syntactic constructs. • Syntactic substitution is for free – part of the λ -converibility inherent in equality. 46

  16. Kind ty type. Type bas ty. Type arrow ty -> ty -> ty. HOAS: Representing the Simply Typed Lambda Calculus Warmup: simple types. � b � = bas � A → B � = arrow � A � � B � 47

  17. Kind tm type. Type app tm -> tm -> tm. Type abs (tm -> tm) -> tm. HOAS: Representing the Simply Typed Lambda Calculus (Closed) λ -terms � M N � = app � M � � N � λ x . M � = abs (x\ � [ x / x ] M � ) � λ λ � x � = x Examples: λ x .λ λ y . x � = abs x\ abs y\ x � λ λ λ λ x .λ λ y .λ λ z . x z ( y z ) � = abs x\ abs y\ abs z\ app (app x z) (app y z) � λ λ λ λ λ x . x x ) ( λ λ x . x x ) � = app (abs x\ app x x) (abs x\ app x x) � ( λ λ λ 48

  18. type. Kind ctx Type emp ctx. Type add ctx -> tm -> ty -> ctx. HOAS: Representing the Typing Relation Γ , x : A ⊢ M : B Γ , x : A ⊢ x : A λ x . M ) : A → B λ Γ ⊢ ( λ Γ ⊢ M : A → B Γ ⊢ N : A Γ ⊢ M N : B 49

  19. type. Kind ctx Type emp ctx. Type add ctx -> tm -> ty -> ctx. HOAS: Representing the Typing Relation Γ , x : A ⊢ M : B Γ , x : A ⊢ x : A λ x . M ) : A → B λ Γ ⊢ ( λ Γ ⊢ M : A → B Γ ⊢ N : A Γ ⊢ M N : B 50

  20. type. Kind ctx Type emp ctx. Type add ctx -> tm -> ty -> ctx. HOAS: Representing the Typing Relation Γ , x : A ⊢ M : B Γ , x : A ⊢ x : A λ x . M ) : A → B λ Γ ⊢ ( λ Γ ⊢ M : A → B Γ ⊢ N : A Γ ⊢ M N : B 51

  21. Define of : ctx -> tm -> ty -> prop by mem (add G X A) X A ; mem (add G Y B) X A := mem G X A. of (add G ?? A) (M ??) B of G (abs x\ M x) (arrow A B) := exists A, of M (arrow A B) /\ of N A ; of G (app M N) B := Define mem : ctx -> tm -> ty -> prop by of G X A := mem G X A ; HOAS: Representing Typing Contexts Γ , x : A ⊢ M : B Γ ⊢ M : A → B Γ ⊢ N : A Γ , x : A ⊢ x : A λ x . M ) : A → B Γ ⊢ M N : B Γ ⊢ ( λ λ 52

  22. Define of : ctx -> tm -> ty -> prop by mem (add G X A) X A ; mem (add G Y B) X A := mem G X A. of (add G ?? A) (M ??) B of G (abs x\ M x) (arrow A B) := exists A, of M (arrow A B) /\ of N A ; of G (app M N) B := Define mem : ctx -> tm -> ty -> prop by of G X A := mem G X A ; HOAS: Representing Typing Contexts Γ , x : A ⊢ M : B Γ ⊢ M : A → B Γ ⊢ N : A Γ , x : A ⊢ x : A λ x . M ) : A → B Γ ⊢ M N : B Γ ⊢ ( λ λ 53

  23. Contexts What does Γ , x : A mean? • x / ∈ fv (Γ) • x / ∈ fv ( A ) { A if x = y • (Γ , x : A )( y ) = Γ( y ) otherwise 54

  24. Names and the ∇ ∇ ( nabla ) Quantifier ∇ ∀ x . F ∀ ∀ For every term M, it is the case that [ M / x ] F is true. ∇ x . F ∇ ∇ For any name n that is not free in F, it is the case that [ n / x ] F is true. Every type is inhabited by an infinite set of names. Terminology: sometimes we say nominal constant instead of name . 55

  25. Some Properties of ∇ ∇ vs. ∀ ∇ ∀ ∀ ∇ x . ∇ ∇ y . x ̸ = y . • ∇ ∇ ∇ • For any name n / ∈ {} , it is that ∇ ∇ y . n ̸ = y . ∇ • For any name n / ∈ {} , for any name m / ∈ { n } , it is that n ̸ = m . • ∀ ∀ x . ∀ ∀ y . x ̸ = y is not provable. ∀ ∀ • Given any term M , it must be that M = M . ∀ x . ∀ ∀ y . p x y ) ⊃ ∀ z . p z z ) . • ( ∀ ∀ ∀ ⊃ ⊃ ( ∀ ∀ ∇ x . ∇ ∇ y . p x y ) ⊃ ∇ z . p z z ) is not provable. • ( ∇ ∇ ∇ ⊃ ⊃ ( ∇ ∇ ∇ x . ∇ ∇ y . p x y means that p holds for any two distinct names. • ∇ ∇ ∇ ∇ z . p z z means that p holds for any name, repeated. • ∇ ∇ 56

  26. Mobility of Binding The equational theory of λ -terms is restated in terms of ∇ . λ x . M ) = ( λ λ x . N ) if and only if ∇ ∇ x . ( M = N ) . ( λ λ λ ∇ Why not ∀ ∀ ? ∀ • Differentiate between the identity function λ λ x . x and the λ constant function λ λ x . c . λ • ∀ ∀ x . ( x = c ) is satisfiable. ∀ ∇ x . ( x = c ) is false, i.e., ¬∇ ∇ x . ( x = c ) is provable. • ∇ ∇ ∇ 57

  27. Names and Equivariance • Formulas are considered equivalent up to a permutation of their free names, known as equivariance. • Example: if m and n are distinct names, then: • p m ≡ p n . • p m n ≡ p n m . • p m m ̸≡ p m n . • Note: terms are not equal up to equivariance! • In Abella, any identifer matching the regexp n[0-9]+ is considered to be a name. 58

  28. Raising Let supp ( F ) stand for the free names in F . ∀ x . F : ∀ ∀ For every term M, it is the case that [ M / x ] F is true. 59

  29. Raising Let supp ( F ) stand for the free names in F . ∀ x . F : ∀ ∀ For every term M with supp ( M ) = {} , it is the case that [ M supp ( F ) / x ] F is true. 60

  30. Raising ∀ x . F : ∀ ∀ For every term M with supp ( M ) = {} , it is the case that [ M supp ( F ) / x ] F is true. • ∀ ∀ x . ∇ ∇ y . p x y ∀ ∇ • For every term M , it is that ∇ ∇ y . p M y . ∇ • For every M , for any name n / ∈ fn ( M ) , it is that p M n . • Therefore M cannot mention n . ∇ y . ∀ ∀ x . p x y • ∇ ∇ ∀ • For any name n / ∈ {} , it is that ∀ ∀ x . p x n . ∀ • For any name n , for every term M , it is that p ( M n ) n . λ x . M ′ where M ′ can have x free. • In other words, M is of the form λ λ • Therefore, M can (indirectly) mention n . 61

  31. of G X A := mem G X A ; Define of : ctx -> tm -> ty -> prop by of G (app M N) B := exists A, of M (arrow A B) /\ of N A ; of G (abs x\ M x) (arrow A B) := nabla x, of (add G x A) (M x) B Back to HOAS: The Typing Relation Γ , x : A ⊢ M : B Γ ⊢ M : A → B Γ ⊢ N : A Γ , x : A ⊢ x : A λ x . M ) : A → B Γ ⊢ M N : B Γ ⊢ ( λ λ 62

  32. of G X A := mem G X A ; Define of : ctx -> tm -> ty -> prop by of G (app M N) B := exists A, of M (arrow A B) /\ of N A ; of G (abs x\ M x) (arrow A B) := nabla x, of (add G x A) (M x) B Back to HOAS: The Typing Relation Γ , x : A ⊢ M : B Γ ⊢ M : A → B Γ ⊢ N : A Γ , x : A ⊢ x : A λ x . M ) : A → B Γ ⊢ M N : B Γ ⊢ ( λ λ 63

  33. of G (abs x\ M x) (arrow A B) := nabla x, of (add G x A) (M x) B forall G M A B, of G (abs x\ M x) (arrow A B) <- nabla x, of (add G x A) (M x) B. ∇ in the Body of a Clause ∇ ∇ means • None of G , M , A , B can mention x . • M can indirectly mention x . 64

  34. 2.8 – Properties of the Typing Relation HOAS: Typing Relation 65

  35. Define eval : tm -> tm -> prop by eval (abs R) (abs R) ; eval (app M N) V := exists R, eval M (abs R) /\ eval (R N) V. HOAS: Substitution The main promise of HOAS: substitution “for free” Notes: • (R N) may be arbitrarily larger than (app M N) . • However, proving (eval (R N) V) will require strictly fewer unfolding steps than (eval (app M N) V) . 66

  36. 2.9 – Subject Reduction HOAS: Subject Reducton (Extended Example) 67

  37. INTERMISSION 68

  38. The Two-Level Logic Approach 69

  39. Outline 1 Focused Minimal Intuitionistic Logic 2 Two-Level Logic Approach 3 Context Structure 4 Examples 70

  40. Meta-Theorems • We have just seen several examples of meta-theorems: • Cut (for substituting in contexts) • Instantiation (for replacing names with terms) • Weakening • Such theorems can be seen as instances of similar meta-theorems for a proof system • If we can isolate this proof system and prove the meta-theorems once and for all, we can avoid a lot of boilerplate. 71

  41. Small Aside: A Bit of Proof Theory Let us start with intuitionistic minimal logic. F , G A F ⇒ ⇒ G Π x . F ::= | ⇒ | Γ , F Γ ::= · | We are going to build a focused proof system for this logic. ⊢ F Goal decomposition sequent Γ ⊢ ⊢ Γ , [ F ] ⊢ ⊢ A Backchaining sequent ⊢ 72

  42. Small Aside: A Bit of Proof Theory Let us start with intuitionistic minimal logic. F , G A F ⇒ ⇒ G Π x . F ::= | ⇒ | Γ , F Γ ::= · | We are going to build a focused proof system for this logic. ⊢ F Goal decomposition sequent Γ ⊢ ⊢ Γ , [ F ] ⊢ ⊢ A Backchaining sequent ⊢ 73

  43. Focused Proof System Goal decomposition Γ , F ⊢ ⊢ G ( x #Γ) ⊢ F ⊢ Γ ⊢ ⊢ ⊢ F ⇒ ⇒ G ⊢ Π x . F ⊢ ⇒ ⊢ Γ ⊢ Γ ⊢ Decision Γ , F , [ F ] ⊢ ⊢ A ⊢ Γ , F ⊢ ⊢ A ⊢ Backchaining ⊢ F Γ , [ G ] ⊢ ⊢ A Γ , [[ t / x ] F ] ⊢ ⊢ A Γ ⊢ ⊢ ⊢ ⊢ Γ , [ F ⇒ ⇒ G ] ⊢ ⊢ A Γ , [Π x . F ] ⊢ ⊢ A Γ , [ A ] ⊢ ⊢ A ⇒ ⊢ ⊢ ⊢ 74

  44. Focused Proof System Goal decomposition Γ , F ⊢ ⊢ G ( x #Γ) ⊢ F ⊢ Γ ⊢ ⊢ ⊢ F ⇒ ⇒ G ⊢ Π x . F ⊢ ⇒ ⊢ Γ ⊢ Γ ⊢ Decision Γ , F , [ F ] ⊢ ⊢ A ⊢ Γ , F ⊢ ⊢ A ⊢ Backchaining ⊢ F Γ , [ G ] ⊢ ⊢ A Γ , [[ t / x ] F ] ⊢ ⊢ A Γ ⊢ ⊢ ⊢ ⊢ Γ , [ F ⇒ ⇒ G ] ⊢ ⊢ A Γ , [Π x . F ] ⊢ ⊢ A Γ , [ A ] ⊢ ⊢ A ⇒ ⊢ ⊢ ⊢ 75

  45. Focused Proof System Goal decomposition Γ , F ⊢ ⊢ G ( x #Γ) ⊢ F ⊢ Γ ⊢ ⊢ ⊢ F ⇒ ⇒ G ⊢ Π x . F ⊢ ⇒ ⊢ Γ ⊢ Γ ⊢ Decision Γ , F , [ F ] ⊢ ⊢ A ⊢ Γ , F ⊢ ⊢ A ⊢ Backchaining ⊢ F Γ , [ G ] ⊢ ⊢ A Γ , [[ t / x ] F ] ⊢ ⊢ A Γ ⊢ ⊢ ⊢ ⊢ Γ , [ F ⇒ ⇒ G ] ⊢ ⊢ A Γ , [Π x . F ] ⊢ ⊢ A Γ , [ A ] ⊢ ⊢ A ⇒ ⊢ ⊢ ⊢ 76

  46. Synthetic (Derived) Rules Imagine Γ = R 1 , R 2 where: R 1 : Π m , n , a , b . of m ( arr a b ) ⇒ ⇒ of n a ⇒ ⇒ of ( app m n ) b . ⇒ ⇒ R 2 : Π r , a , b . (Π x . of x a ⇒ ⇒ of ( r x ) b ) ⇒ ⇒ of ( abs r ) ( arr a b ) . ⇒ ⇒ Consider the result of deciding on R 1 and R 2 . ⊢ of M ( arr A B ) ⊢ of N A Γ , [ of ( app M N ) B ] ⊢ ⊢ C Γ ⊢ ⊢ Γ ⊢ ⊢ ⊢ Γ , [[ M / m , N / n , A / a , B / b ] · · · ⇒ ⊢ C ⇒ ⇒ · · · ⇒ ⇒ ⇒ · · · ] ⊢ ⊢ Γ , [ R 1 ] ⊢ ⊢ C ⊢ ⊢ C Γ ⊢ ⊢ ⊢ of M ( arr A B ) ⊢ of N A Γ ⊢ ⊢ Γ ⊢ ⊢ ⊢ of ( app M N ) B Γ ⊢ ⊢ 77

  47. Synthetic (Derived) Rules Imagine Γ = R 1 , R 2 where: R 1 : Π m , n , a , b . of m ( arr a b ) ⇒ ⇒ of n a ⇒ ⇒ of ( app m n ) b . ⇒ ⇒ R 2 : Π r , a , b . (Π x . of x a ⇒ ⇒ of ( r x ) b ) ⇒ ⇒ of ( abs r ) ( arr a b ) . ⇒ ⇒ Consider the result of deciding on R 1 and R 2 . ⊢ of M ( arr A B ) ⊢ of N A Γ , [ of ( app M N ) B ] ⊢ ⊢ C Γ ⊢ ⊢ Γ ⊢ ⊢ ⊢ Γ , [[ M / m , N / n , A / a , B / b ] · · · ⇒ ⊢ C ⇒ ⇒ · · · ⇒ ⇒ ⇒ · · · ] ⊢ ⊢ Γ , [ R 1 ] ⊢ ⊢ C ⊢ ⊢ C Γ ⊢ ⊢ ⊢ of M ( arr A B ) ⊢ of N A Γ ⊢ ⊢ Γ ⊢ ⊢ ⊢ of ( app M N ) B Γ ⊢ ⊢ 78

  48. Synthetic (Derived) Rules Imagine Γ = R 1 , R 2 where: R 1 : Π m , n , a , b . of m ( arr a b ) ⇒ ⇒ of n a ⇒ ⇒ of ( app m n ) b . ⇒ ⇒ R 2 : Π r , a , b . (Π x . of x a ⇒ ⇒ of ( r x ) b ) ⇒ ⇒ of ( abs r ) ( arr a b ) . ⇒ ⇒ Consider the result of deciding on R 1 and R 2 . ⊢ of M ( arr A B ) ⊢ of N A Γ , [ of ( app M N ) B ] ⊢ ⊢ C Γ ⊢ ⊢ Γ ⊢ ⊢ ⊢ Γ , [[ M / m , N / n , A / a , B / b ] · · · ⇒ ⊢ C ⇒ ⇒ · · · ⇒ ⇒ ⇒ · · · ] ⊢ ⊢ Γ , [ R 1 ] ⊢ ⊢ C ⊢ ⊢ C Γ ⊢ ⊢ ⊢ of M ( arr A B ) ⊢ of N A Γ ⊢ ⊢ Γ ⊢ ⊢ ⊢ of ( app M N ) B Γ ⊢ ⊢ 79

  49. Synthetic (Derived) Rules Imagine Γ = R 1 , R 2 where: R 1 : Π m , n , a , b . of m ( arr a b ) ⇒ ⇒ of n a ⇒ ⇒ of ( app m n ) b . ⇒ ⇒ R 2 : Π r , a , b . (Π x . of x a ⇒ ⇒ of ( r x ) b ) ⇒ ⇒ of ( abs r ) ( arr a b ) . ⇒ ⇒ Consider the result of deciding on R 1 and R 2 . ⊢ of M ( arr A B ) ⊢ of N A Γ , [ of ( app M N ) B ] ⊢ ⊢ C Γ ⊢ ⊢ Γ ⊢ ⊢ ⊢ Γ , [[ M / m , N / n , A / a , B / b ] · · · ⇒ ⊢ C ⇒ ⇒ · · · ⇒ ⇒ ⇒ · · · ] ⊢ ⊢ Γ , [ R 1 ] ⊢ ⊢ C ⊢ ⊢ C Γ ⊢ ⊢ ⊢ of M ( arr A B ) ⊢ of N A Γ ⊢ ⊢ Γ ⊢ ⊢ ⊢ of ( app M N ) B Γ ⊢ ⊢ 80

  50. Synthetic (Derived) Rules Imagine Γ = R 1 , R 2 where: R 1 : Π m , n , a , b . of m ( arr a b ) ⇒ ⇒ of n a ⇒ ⇒ of ( app m n ) b . ⇒ ⇒ R 2 : Π r , a , b . (Π x . of x a ⇒ ⇒ of ( r x ) b ) ⇒ ⇒ of ( abs r ) ( arr a b ) . ⇒ ⇒ Consider the result of deciding on R 1 and R 2 . ⊢ of M ( arr A B ) ⊢ of N A Γ , [ of ( app M N ) B ] ⊢ ⊢ of ( app M N ) B Γ ⊢ ⊢ Γ ⊢ ⊢ ⊢ Γ , [[ M / m , N / n , A / a , B / b ] · · · ⇒ ⊢ of ( app M N ) B ⇒ ⇒ · · · ⇒ ⇒ ⇒ · · · ] ⊢ ⊢ Γ , [ R 1 ] ⊢ ⊢ of ( app M N ) B ⊢ ⊢ of ( app M N ) B Γ ⊢ ⊢ ⊢ of M ( arr A B ) ⊢ of N A Γ ⊢ ⊢ Γ ⊢ ⊢ ⊢ of ( app M N ) B Γ ⊢ ⊢ 81

  51. Synthetic (Derived) Rules Imagine Γ = R 1 , R 2 where: R 1 : Π m , n , a , b . of m ( arr a b ) ⇒ ⇒ of n a ⇒ ⇒ of ( app m n ) b . ⇒ ⇒ R 2 : Π r , a , b . (Π x . of x a ⇒ ⇒ of ( r x ) b ) ⇒ ⇒ of ( abs r ) ( arr a b ) . ⇒ ⇒ Consider the result of deciding on R 1 and R 2 . ⊢ of M ( arr A B ) ⊢ of N A Γ , [ of ( app M N ) B ] ⊢ ⊢ of ( app M N ) B Γ ⊢ ⊢ Γ ⊢ ⊢ ⊢ Γ , [[ M / m , N / n , A / a , B / b ] · · · ⇒ ⊢ of ( app M N ) B ⇒ ⇒ · · · ⇒ ⇒ ⇒ · · · ] ⊢ ⊢ Γ , [ R 1 ] ⊢ ⊢ of ( app M N ) B ⊢ ⊢ of ( app M N ) B Γ ⊢ ⊢ ⊢ of M ( arr A B ) ⊢ of N A Γ ⊢ ⊢ Γ ⊢ ⊢ ⊢ of ( app M N ) B Γ ⊢ ⊢ 82

  52. Synthetic (Derived) Rules Imagine Γ = R 1 , R 2 where: R 1 : Π m , n , a , b . of m ( arr a b ) ⇒ ⇒ of n a ⇒ ⇒ of ( app m n ) b . ⇒ ⇒ R 2 : Π r , a , b . (Π x . of x a ⇒ ⇒ of ( r x ) b ) ⇒ ⇒ of ( abs r ) ( arr a b ) . ⇒ ⇒ Consider the result of deciding on R 1 and R 2 . ⊢ of M ( arr A B ) ⊢ of N A Γ , [ of ( app M N ) B ] ⊢ ⊢ of ( app M N ) B Γ ⊢ ⊢ Γ ⊢ ⊢ ⊢ Γ , [[ M / m , N / n , A / a , B / b ] · · · ⇒ ⊢ of ( app M N ) B ⇒ ⇒ · · · ⇒ ⇒ ⇒ · · · ] ⊢ ⊢ Γ , [ R 1 ] ⊢ ⊢ of ( app M N ) B ⊢ ⊢ of ( app M N ) B Γ ⊢ ⊢ ⊢ of M ( arr A B ) ⊢ of N A Γ ⊢ ⊢ Γ ⊢ ⊢ ⊢ of ( app M N ) B Γ ⊢ ⊢ 83

  53. Deciding on R 2 1 Γ , [ of ( abs R ) ( arr A B )] ⊢ ⊢ of ( abs R ) ( arr A B ) ⊢ Γ , [[ R / r , A / a , B / b ](Π x . · · · ⇒ ⊢ of ( abs R ) ( arr A B ) ⇒ ⇒ ⊢ ⇒ · · · ) ⇒ ⇒ · · · ] ⊢ Γ , [ R 2 ] ⊢ ⊢ of ( abs R ) ( arr A B ) ⊢ ⊢ of ( abs R ) ( arr A B ) Γ ⊢ ⊢ where 1 is: ( x #Γ) Γ , of x A ⊢ ⊢ of ( R x ) B ⊢ ⊢ Π x . of x A ⇒ ⇒ of ( R x ) B Γ ⊢ ⊢ ⇒ So: ( x #Γ) Γ , of x A ⊢ ⊢ of ( R x ) B ⊢ ⊢ of ( abs R ) ( arr A B ) Γ ⊢ ⊢ 84

  54. Deciding on R 2 1 Γ , [ of ( abs R ) ( arr A B )] ⊢ ⊢ of ( abs R ) ( arr A B ) ⊢ Γ , [[ R / r , A / a , B / b ](Π x . · · · ⇒ ⊢ of ( abs R ) ( arr A B ) ⇒ ⇒ ⊢ ⇒ · · · ) ⇒ ⇒ · · · ] ⊢ Γ , [ R 2 ] ⊢ ⊢ of ( abs R ) ( arr A B ) ⊢ ⊢ of ( abs R ) ( arr A B ) Γ ⊢ ⊢ where 1 is: ( x #Γ) Γ , of x A ⊢ ⊢ of ( R x ) B ⊢ ⊢ Π x . of x A ⇒ ⇒ of ( R x ) B Γ ⊢ ⊢ ⇒ So: ( x #Γ) Γ , of x A ⊢ ⊢ of ( R x ) B ⊢ ⊢ of ( abs R ) ( arr A B ) Γ ⊢ ⊢ 85

  55. Synthetic Rules vs. SOS rules ⊢ M : A → B ⊢ N : A ⊢ of M ( arr A B ) ⊢ of N A Γ ⊢ Γ ⊢ Γ ⊢ Γ ⊢ ⊢ ⊢ ⊢ ⊢ ⊢ ( M N ) : B ⊢ of ( app M N ) B Γ ⊢ ⊢ Γ ⊢ ⊢ Γ , x : A ⊢ ⊢ M : B ( x #Γ) Γ , of x A ⊢ ⊢ of ( R x ) B ⊢ ⊢ λ x . M ) : A → B ⊢ of ( abs R ) ( arr A B ) Γ ⊢ ⊢ ( λ ⊢ λ Γ ⊢ ⊢ Reasoning about SOS derivations is isomorphic to reasoning about focused derivations for its minimal theory. 86

  56. Synthetic Rules vs. SOS rules ⊢ M : A → B ⊢ N : A ⊢ of M ( arr A B ) ⊢ of N A Γ ⊢ Γ ⊢ Γ ⊢ Γ ⊢ ⊢ ⊢ ⊢ ⊢ ⊢ ( M N ) : B ⊢ of ( app M N ) B Γ ⊢ ⊢ Γ ⊢ ⊢ Γ , x : A ⊢ ⊢ M : B ( x #Γ) Γ , of x A ⊢ ⊢ of ( R x ) B ⊢ ⊢ λ x . M ) : A → B ⊢ of ( abs R ) ( arr A B ) Γ ⊢ ⊢ ( λ ⊢ λ Γ ⊢ ⊢ Reasoning about SOS derivations is isomorphic to reasoning about focused derivations for its minimal theory. 87

  57. o -> olist -> olist. seq L F type. Type => o -> o -> o. Type pi (A -> o) -> o. Kind olist type Type nil olist. Type :: Kind o Define member : o -> olist -> prop by ... bch L F A Minimal Logic Definable in G Sequent Encoding ⊢ F Γ ⊢ ⊢ Γ , [ F ] ⊢ ⊢ A ⊢ 88

  58. o -> olist -> olist. seq L F type. Type => o -> o -> o. Type pi (A -> o) -> o. Kind olist type Type nil olist. Type :: Kind o Define member : o -> olist -> prop by ... bch L F A Minimal Logic Definable in G Sequent Encoding ⊢ F Γ ⊢ ⊢ Γ , [ F ] ⊢ ⊢ A ⊢ 89

  59. seq L A bch L (F => G) A := seq L F /\ bch L G A ; bch : olist -> o -> o -> prop by bch L A A. seq L (F => G) := seq (F :: L) G ; seq L (pi F) := nabla x, seq L (F x) ; := exists T, bch L (F T) A Define seq : olist -> o -> prop, := exists F, member F L /\ bch L F A ; bch L (pi F) A Focused Minimal Sequent Calculus in G % goal reduction % decision % backchaining 90

  60. Theorem cut : forall L C F, seq L C -> seq (C :: L) F -> seq L F. Theorem inst : forall L F, nabla x, seq (L x) (F x) -> forall T, seq (L T) (F T). Theorem monotone : forall L1 L2 F, (forall G, member G L1 -> member G L2) -> seq L1 F -> seq L2 F. Meta-Theory of Minimal Sequent Calculus %% L1 ⊆ ⊆ L2 ⊆ 91

  61. {L |- F} seq L F bch L F A {L, [F] |- A} The Two Level Logic Approach of Abella • Specification Logic • Focused sequent calculus for minimal intuitionistic logic • Shares the type system of G , but formulas of type o • Concrete syntax the same as λ Prolog • Reasoning Logic • Inductive definition of the specification logic proof system • Inductive reasoning about specification logic derivations • Syntactic sugar: 92

  62. 3.1 – Typing and Subject Reduction Example: STLC Specification 93

  63. type abs ty -> (tm -> tm) -> tm. ---- of (abs A R) (arr A B) :- pi x\ of x A => of (R x) B. Theorem type_uniq : forall M A B, {of M A} -> {of M B} -> A = B. Theorem type_uniq_open : forall L M A B, {L |- of M A} -> {L |- of M B} -> A = B. Uniqueness of Typing Change to a Church style representation: Want to show that every term has a unique type. Need to generalize! 94

  64. type abs ty -> (tm -> tm) -> tm. ---- of (abs A R) (arr A B) :- pi x\ of x A => of (R x) B. Theorem type_uniq : forall M A B, {of M A} -> {of M B} -> A = B. Theorem type_uniq_open : forall L M A B, {L |- of M A} -> {L |- of M B} -> A = B. Uniqueness of Typing Change to a Church style representation: Want to show that every term has a unique type. Need to generalize! 95

  65. type abs ty -> (tm -> tm) -> tm. ---- of (abs A R) (arr A B) :- pi x\ of x A => of (R x) B. Theorem type_uniq : forall M A B, {of M A} -> {of M B} -> A = B. Theorem type_uniq_open : forall L M A B, {L |- of M A} -> {L |- of M B} -> A = B. Uniqueness of Typing Change to a Church style representation: Want to show that every term has a unique type. Need to generalize! 96

  66. Define ctx : olist -> prop by ctx nil ; ctx (of X A :: L) := ctx L. Structure of Contexts • The typing dynamic context L is a list of of assumptions. • Already seen how to inductively define the structure of lists. • Therefore: • But this does not capture X # L ! 97

  67. forall L A X, ctx L -> ctx (of X A :: L). forall L A, nabla x, ctx L -> ctx (of x A :: L). forall L A, ctx L -> nabla x, ctx (of x A :: L). Define ctx : olist -> prop by ctx nil ; nabla x, ctx (of x A :: L) := ctx L. “ ∇ In The Head” Meaning of the second clause: Let us change the “flavor” of X . Equivalent to: This suggests: 98

  68. forall L A X, ctx L -> ctx (of X A :: L). forall L A, nabla x, ctx L -> ctx (of x A :: L). forall L A, ctx L -> nabla x, ctx (of x A :: L). Define ctx : olist -> prop by ctx nil ; nabla x, ctx (of x A :: L) := ctx L. “ ∇ In The Head” Meaning of the second clause: Let us change the “flavor” of X . Equivalent to: This suggests: 99

  69. forall L A X, ctx L -> ctx (of X A :: L). forall L A, nabla x, ctx L -> ctx (of x A :: L). forall L A, ctx L -> nabla x, ctx (of x A :: L). Define ctx : olist -> prop by ctx nil ; nabla x, ctx (of x A :: L) := ctx L. “ ∇ In The Head” Meaning of the second clause: Let us change the “flavor” of X . Equivalent to: This suggests: 100

Recommend


More recommend