proof%theory%and%its%role%in% …

20
Proof Theory and Its Role in Programming Language Research Frank Pfenning Carnegie Mellon University January 14, 2015 PLMW 2015, Mumbai 1

Upload: others

Post on 11-Nov-2021

5 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Proof%Theory%and%Its%Role%in% …

Proof  Theory  and  Its  Role  in  Programming  Language  Research  

Frank  Pfenning  Carnegie  Mellon  University  

January  14,  2015   PLMW  2015,  Mumbai   1  

Page 2: Proof%Theory%and%Its%Role%in% …

How  Do  We  Write  Correct  Programs  

•  We  rarely  do,  but  …  •  In  pracLce,  programming  and  informal  reasoning  go  hand  in  hand  – OperaLonal:  how  does  the  program  execute  

– Logical:  what  does  it  accomplish  

•  Decompose  into  parts  (e.g.,  funcLons,  modules)  so  we  can  reason  locally  

January  14,  2015   PLMW  2015,  Mumbai   2  

Page 3: Proof%Theory%and%Its%Role%in% …

Coherence  

•  OperaLonal  and  logical  views  should  be  coherent  

•  And  both  should  be  as  simple  as  possible  

•  Composed  of  parts  we  can  reason  about  separately  as  much  as  possible  – Not  just  for  programs,  but  for  the  language  itself  

•  Logic  is  inevitable  —  why  wait?  

January  14,  2015   PLMW  2015,  Mumbai   3  

Page 4: Proof%Theory%and%Its%Role%in% …

Codesign  of  ComputaLon  and  Logic  

•  Fortunately,  logic  is  computaLonal  •  Key:  creaLng  a  mutual  fit  —  requires  considerable  ingenuity,  persistence,  luck  –  RunLme  code  generaLon  and  ??  –  ParLal  evaluaLon  and  ??  –  Dead  code  eliminaLon  and  ??  –  Distributed  computaLon  and  ??  – Message-­‐passing  concurrency  and  ??  –  ??  and  lax  logic  –  ??  and  temporal  logic  –  ??  and  epistemic  logic  –  ??  and  ordered  logic  

January  14,  2015   PLMW  2015,  Mumbai   4  

Page 5: Proof%Theory%and%Its%Role%in% …

Key  Ingredients  

•  Judgments,  leading  to  proposiLons  •  Basic  style  of  proof  system  – Natural  deducLon  – Sequent  calculus  – AxiomaLc  proof  system  – Binary  entailment  

•  Proof  reducLon  and  equality  

January  14,  2015   PLMW  2015,  Mumbai   5  

Page 6: Proof%Theory%and%Its%Role%in% …

Example:  HypotheLcal  Judgments  

•  Basic  judgment:  A  true,  for  a  proposiLon  A  •  HypotheLcal  judgment  

•  Defined  via  subsLtuLon  property  (not  rule)  

•  Which  entails  hypothesis  rule  

January  14,  2015   PLMW  2015,  Mumbai   6  

Page 7: Proof%Theory%and%Its%Role%in% …

With  Proof  Terms  

•  Basic  judgment:    M  :  A    •  HypotheLcal  judgment  =  typing  judgment  

•  Defined  via  subsLtuLon  property  (dashed  line),  which  entails  the  hypothesis  rule  

 

January  14,  2015   PLMW  2015,  Mumbai   7  

Page 8: Proof%Theory%and%Its%Role%in% …

Internalize  HypotheLcal  Judgment  

•  Form  a  proposiLon  whose  definiLon  (via  an  introducLon  rule)  reflects  the  judgment  

•  Use  the  definiLon  of  the  judgment,  to  determine  the  eliminaLon  rule  

January  14,  2015   PLMW  2015,  Mumbai   8  

Page 9: Proof%Theory%and%Its%Role%in% …

Terms  Construct  and  Apply  FuncLons  

•  Logical  rules  become  familiar  typing  rules  

•  IntroducLon  rules  construct  terms  

•  EliminaLon  rules  destruct  term  

•  ComputaLon  arises  when  a  destructor  is  applied  to  a  constructor  

January  14,  2015   PLMW  2015,  Mumbai   9  

Page 10: Proof%Theory%and%Its%Role%in% …

Harmony  in  Natural  DeducLon  

•  IntroducLon  rules  construct  proofs  that  verify  •  EliminaLon  rules  construct  proof  that  use  

•  Harmony  between  intro  and  elim  rules  – Any  introducLon  of  A  followed  an  eliminaLon  of  A  can  be  reduced  (local  reducLon)  

– Any  proposiLon  A  can  be  proved  by  an  introducLon  (local  expansion)  

January  14,  2015   PLMW  2015,  Mumbai   10  

Page 11: Proof%Theory%and%Its%Role%in% …

Proof  ReducLon  is  ComputaLon  

•  On  proofs  

•  On  proof  terms  

January  14,  2015   PLMW  2015,  Mumbai   11  

Page 12: Proof%Theory%and%Its%Role%in% …

Example:  RunLme  Code  GeneraLon  

•  Key  computaLonal  idea:  we  have  a  quoted  source  expression  available  at  runLme  

•  DisLnguish  – Ordinary  variables,  bound  to  values  – Expression  variables,  bound  to  source  code  

•  Need  to  quote  and  evaluate  expressions  –  In  a  logically  correct  way  

January  14,  2015   PLMW  2015,  Mumbai   12  

Page 13: Proof%Theory%and%Its%Role%in% …

Categorical  Judgment  

•  Judgment  form,  with  variables  

•  We  can  only  subsLtute  an  expression  without  reference  to  value  vars  for  an  expression  var  

 

January  14,  2015   PLMW  2015,  Mumbai   13  

Page 14: Proof%Theory%and%Its%Role%in% …

QuotaLon  ConLnued  

•  We  also  have  a  new  hypothesis  rule  

•  We  would  like  to  internalize  “A  stands  for  a  source  expression”  as  a  proposiLon  

January  14,  2015   PLMW  2015,  Mumbai   14  

Page 15: Proof%Theory%and%Its%Role%in% …

Internalizing  a  Categorical  Judgment  

•  Judgment  u:A  means  A  is  valid  

•  One  can  check  harmony  

January  14,  2015   PLMW  2015,  Mumbai   15  

Page 16: Proof%Theory%and%Its%Role%in% …

Which  Logic  is  This?  

•  AxiomaLcally,  we  find  

•  This  defines  the  intuiLonisLc  modal  logic  S4  •  ConservaLvely  extends  intuiLonisLc  logic  •  We  can  have  a  type  theory  with  quote/eval  

January  14,  2015   PLMW  2015,  Mumbai   16  

Page 17: Proof%Theory%and%Its%Role%in% …

Validity  and  Necessity  

•  Expression  variables  correspond  to  assumpLons  of  validity  (u:A  ⟺  A  valid)  

•  The  box  modality  internalizes  this  as  a  proposiLon  (A  valid  ⟺  ☐A  true)  

•  Judgmentally,  we  only  need  hypotheLcal  and  categorical  judgments  – Natural  deducLon  and  harmony  do  the  rest  

– Generally,  very  limle  “new”  is  needed  

January  14,  2015   PLMW  2015,  Mumbai   17  

Page 18: Proof%Theory%and%Its%Role%in% …

Codesign  Revisited  

•  RunLme  code  generaLon  and  IS4  (A  valid)  •  ParLal  evaluaLon  and  temporal  logic  (A  @  t)  •  Dead  code  eliminaLon  and  modal  logic  IT  (A  irr)  •  Distributed  computaLon  and  IS5  (A  @  w)  •  Concurrency  and  (intuiLonisLc)  linear  logic  (linear  hypotheLcal  judgment)  

•  Generic  effects  and  lax  logic  (A  lax)  •  ??  and  epistemic  logic  (K  knows  A)  •  ??  and  ordered  logic  (ordered  hyp.  Judgment)  

January  14,  2015   PLMW  2015,  Mumbai   18  

Page 19: Proof%Theory%and%Its%Role%in% …

Summary  

•  Codesign  of  programming  language  and  its  logic  can  be  powerful  – You’ll  know  when  it  is  right  – But  it  is  hard  

•  There  are  many  parameters  – Style  of  system  (ND,  SEQ,  HIL,  …)  –  Judgments  (hypotheLcal,  categorical,  linear,  …)  – RelaLng  proof  reducLon  to  computaLon  – Equality,  for  a  full  type  theory  

January  14,  2015   PLMW  2015,  Mumbai   19  

Page 20: Proof%Theory%and%Its%Role%in% …

Some  Advice  

•  Focus  on  what  you  can  express,  not  what  you  can’t  

•  Measure  success  by  the  constructs  omimed,  not  those  included  

•  Design,  program  and  reason,  iterate  •  Syntax  is  important  •  SemanLcs  is  even  more  important,  both  operaLonal  and  logical  

•  Know  when  to  give  up  

January  14,  2015   PLMW  2015,  Mumbai   20