CIS 500: Software Foundations. November 8, Solutions
|
|
- Madison James
- 5 years ago
- Views:
Transcription
1 CIS 500: Software Foundations Midterm II November 8, 2018 Solutions
2 1. (8 points) Put an X in the True or False box for each statement. (1) For every b : bexp and c1, c2 : com, either the command IFB b THEN c1 ELSE c2 FI is equivalent to c1 or it is equivalent to c2. True False (Counterexample: Let b be X.<= Y, let c1 be Z ::= 0, and let c2 be Z ::= 1.) (2) The big-step evaluation of Imp programs can naturally be expressed in Coq as either an Inductive relation or a Fixpoint. True False (Since Imp programs may not terminate, defining evaluation using Fixpoint is awkward.) (3) For every c : com and P, Q, R : assertion, if { P } c { Q } is valid, then { P R } c { Q R } is valid. True False (4) For every c : com, and st, st, st : state, if st =[ c ]=> st and st =[ c ]=> st, then st = st. True False (Counterexample: c = X::=X.+1 and b2 = false) (5) For every c : com, b : bexp, and P, Q : assertion, if the hoare triple { P } IFB b THEN c ELSE SKIP FI { Q } is valid, then { P } c { Q } is valid. True False (Counterexample: Let P be X <> 1, Q be X <> 1, and c = IFB b THEN SKIP ELSE X ::= 1 FI. Should be { P b } c { Q }) (6) For every b : bexp and c : com, the programs and WHILE b DO c END WHILE b DO c ;; IFB b THEN c ELSE SKIP END END are equivalent. True False 1
3 (7) For every b : bexp and c1, c2 : com, the programs and WHILE b DO c1 END WHILE b DO c1 END;; WHILE b DO c2 END are equivalent. True False (8) For every b1, b2 : bexp and c : com, the programs and WHILE b1 DO IFB b2 THEN c ELSE SKIP END END WHILE b2 DO IFB b1 THEN c ELSE SKIP END END are equivalent. True False (Counterexample: b1 = true and b2 = false) 2
4 2. (15 points) Recall that the assertion P appearing in the hoare_while rule (repeated for reference on page 5 in the handout) is called the loop invariant. For each loop shown below, check the box next to each assertion that is a valid loop invariant that is, { P b } c { P }, where c is the body of the loop. There may be zero or more than one of them. (1) WHILE!(X.<= Z) DO X ::= X.- 1 END X < 10 X = 10 X = 0 X + Z <> 0 Z = 1 Z < 1 True None of the above apply (2) WHILE!(X.= Y) DO Y ::= X;; X ::= Y END X > 5 Y > 5 X + Y > 1 Z = 3 + X X * Y <= 1 X = 20 None of the above apply (3) WHILE!(X.= Y) DO Y ::= Z;; Z ::= Z.+ 1 END Y < 5 Y > 5 X = Z False Y = Z + 1 Y * Z = X X = 1 None of the above apply 3
5 (4) WHILE X.<= 16 DO X ::= 10.- Y;; Y ::= 1.+ Y END Y < 5 X > 10 X < 10 X + Y < 10 X + Y = 10 X + Y > 10 None of the above apply (5) WHILE!(X.+ Y.= 0) DO X ::= 10.- Y;; Y ::= 10.- X END Y > X X > Y X - Y < X + Y X + Y > X X + Y = X X + Y > Y None of the above apply 4
6 3. (16 points) For each Hoare triple below, give an invariant for the WHILE loop that will allows us to prove the triple. As usual, m and n are arbitrary values of type nat. (1) {{ X = m /\ Y = n }} Z ::= 0;; WHILE!(X.= 0.&& Y.= 0) DO IFB!(X.= 0) THEN X ::= X.- 1;; Z ::= Z.+ 1 ELSE SKIP FI;; IFB!(Y.= 0) THEN Y ::= Y.- 1;; Z ::= Z.+ 1 ELSE SKIP FI {{ Invariant goes here }} END {{ Z = m + n }} Invariant = Z + X + Y = m + n (2) {{ X = m }} Y ::= 0;; IFB n.= 0 THEN Z ::= 1 ELSE Z ::= 0;; WHILE n.<= X DO X ::= X.- n Y ::= Y.+ 1 {{ Invariant goes here }} END FI {{ (Z = 0 /\ n * Y + X = m /\ X < n) \/ (Z = 1 /\ n = 0 /\ Y = 0) }}. Invariant = Z = 0 /\ n * Y + X = m 5
7 (3) (The min and max functions are defined on page 10 of the handout.) {{ X = m /\ Y = n }} Z ::= 0;; WHILE Z.= 0 DO IFB!(X.<= Y) THEN W ::= Y;; Y ::= X;; X ::= W ELSE Z ::= 1 FI {{ Invariant goes here }} END {{ X = min m n /\ Y = max m n }} Invariant = (X = min m n /\ Y = max m n) \/ (X = m /\ Y = n /\ Z = 0) or (Z <> 0 -> X = min m n /\ Y = max m n) \/ (X = m /\ Y = n) (4) (This command divides an even value stored in X by two.) {{ X = 2 * m }} Y ::= 0;; WHILE!(X.<= Y) DO X ::= X.- 1;; Y ::= Y.+ 1 {{ Invariant goes here }} END {{ X = m }} Invariant = X + Y = 2 * m /\ Y < X + 2 6
8 4. (12 points) Translate each of the following informal specifications into a precise Hoare triple by filling in appropriate pre- and postconditions. To reduce clutter, please use informal paper-andpencil notation when writing assertions (e.g., write X = 0 rather than fun st => st X = 0). For example, if the informal specification is The command c increases the value of X by 1, an appropriate pre- and postcondition might be {{X = m}} c {{X = m + 1}}. (1) The command c sets Z to 1 if the initial value of X is between the initial values of W and Y (inclusive); otherwise, it sets Z to 0. c {{ }} {{ }} W = m /\ X = n /\ Y = p (Z = 1 /\ m <= n /\ n <= p) \/ (Z = 0 /\ (n < m \/ p < n)) (2) The command c computes the sum of X and Y, diverges if it is 10 or more, and leaves the sum in Z otherwise. c {{ }} {{ }} X = m /\ Y = n Z = m + n /\ Z < 10 (3) The command c sets Z to the minimum of the three numbers initially stored in X, Y, Z. c {{ }} {{ }} X = m /\ Y = n /\ Z = p (Z = m \/ Z = n \/ Z = p) /\ Z <= m /\ Z <= n /\ Z <= p Alternatively, the postcondition can use a function from the appendix: {{ }} Z = min m (min n p) 7
9 5. (10 points) Recall the definition of what it means for a term t to be a normal form of a relation R: Definition normal_form {X : Type} (R : relation X) (t : X) : Prop := ~ exists t, R t t. (1) Give a complete and precise description, in English, of all the Imp arithmetic expressions a : aexp that are normal forms for the astep relation (i.e., for which the proposition normal_form (astep st) a holds for all states st). Answer: For any natural number n, ANum n is in normal form. (2) Give a complete and precise description of all the Imp commands c and states st such that the pair (c,st) is a normal form for the cstep relation. Answer: The only Imp program in normal form is SKIP; it can be paired with any state. (3) Define informally what it means for a step relation to be normalizing. Answer: A step relation is normalizing if, from any starting state, it reaches a normal form in a finite number of steps. (4) Give an informal definition of strong progress. Answer: A relation has the strong progress property if every t either is a value or can take a step. (5) Does strong progress imply termination? Yes No 8
10 6. [Standard Track Only] (5 points) Recall that a Hoare triple { P } c { Q } is valid if, whenever st is a state satisfying P and st =[ c ]=> st, the final state st satisfies Q, and { P } c { Q } is invalid if it is not valid. Consider the following additional properties of Hoare triples: { P } c { Q } is nontrivial if there is some pair of starting and ending states st and st such that st satisfies P and st =[ c ]=> st (i.e., if c sometimes terminates when started on a state satisfying P). It is trivial if c never terminates when started on a state satisfying P. { P } c { Q } is quite valid if it is nontrivial and valid. { P } c { Q } is quite invalid if { P } c { Q } is quite valid. { P } c { Q } is less than valid if it is neither valid nor quite invalid. To get warmed up, let s check how these terms are related. (Please mark the appropriate box.) (1) If { P } c { Q } is less than valid, then it is nontrivial. True False (2) If { P } c { Q } is quite invalid, then it is nontrivial. True False (3) If { P } c { Q } is less than valid, then it is invalid. True False (4) If { P } c { Q } is nontrivial, then it is either quite valid or quite invalid. True False (5) If { P } c { Q } is trivial, then it is valid. True False 9
11 7. [Standard Track Only] (14 points) (Continuing the previous problem) Now, for each of the following Hoare triples, choose the property that correctly describes it: (1) {{ X = 0 }} WHILE!(X.= 0) DO SKIP END {{ False }} trivial quite valid less than valid quite invalid (2) {{ True }} WHILE!(X.<= 1) DO X ::= X.- 1 END {{ X = 0 }} trivial quite valid less than valid quite invalid (3) {{ 1 <= Z }} IFB Z.<= 2 THEN Z ::= Z.+ 1 ELSE SKIP FI {{ 2 <= Z }} trivial quite valid less than valid quite invalid (4) {{ X < Z }} WHILE!(Z.<= X) DO X ::= X.+ 1;; Z ::= Z.- 1 END {{ X = Z }} trivial quite valid less than valid quite invalid (5) {{ X <= 1 /\ Y = 1 }} WHILE X.<= Y DO X ::= X.* Y END {{ Y < X }} trivial quite valid less than valid quite invalid (6) {{ X <= 1 }} WHILE X.= 1 DO SKIP END {{ X <= 1 }} trivial quite valid less than valid quite invalid (7) {{ True }} WHILE X.= Y DO X ::= X.+ 1;; Y ::= Y.+ 1 END {{ X = Y }} trivial quite valid less than valid quite invalid 10
12 8. [Advanced Track Only] (19 points) Below is the start of a detailed informal proof that the program WHILE!(X.= Y) DO X ::= X.+ 1 END is equivalent to this one: IFB X.<= Y THEN X ::= Y ELSE WHILE true DO SKIP END FI Fill in the proof for claim (1) below. You may freely use the lemmas about updating total maps from Maps.v (repeated on page 1 of the handout, for reference) without explicitly saying you are doing so. Use the next page if you need more space. Proof: Let c1 be the first program and c2 the second. The definition of equivalence says that, given states st and st, we must show that (1) st =[ c1 ]=> st implies st =[ c2 ]=> st and (2) st =[ c2 ]=> st implies st =[ c1 ]=> st. Fill in just the proof of claim (1)... Solution, variant 1: We first show, by induction on a derivation of st =[c1]=> st, that st X <= st Y and st = (X!-> st Y; st). The last rule in this derivation must be either E_WhileFalse or E_WhileTrue. E_WhileFalse: The premises of the rule give us st = st and beval st (!(X.= Y)) = false, i.e., st X = st Y. It follows by the definition of <= that st X <= st Y and from the properties of map update that st = (X!-> st Y; st). E_WhileTrue: The premises of the rule give us st =[X::=X.+1]=> st and st =[c1]=> st (and beval st (!(X.= Y)) = false, though we do not use this). The induction hypothesis gives us st X <= st Y and st = (X!-> st Y; st ). Now, the final rule in the derivation of st =[X::=X.+1]=> st must be E_Ass, so st = (X!-> st X + 1; st), hence st X < st X and st Y = st Y, and so st X <= st Y. Moreover, st and st differ only at X, so (X!-> st Y; st ) = (X!-> st Y; st) by the properties of map update. Thus, st = (X!-> st Y; st) as required. To finish, observe that, by E_Ass, st =[X::=Y]=> (X!->Y; st). Using the fact that st X <= st Y, rule E_IfTrue yields st =[c2]=> (X!->Y; st) = st. Variant 2: We show, by induction on a derivation of st =[c1]=> st, that st =[c2]=> st. Since c1 is a WHILE command, there are two cases to consider: The final rule is E_WhileFalse. Then beval st (!(X.=Y)) = false, so st X = st Y, and st = st. It follows that st X <= st Y; from this, E_IfTrue and E_Ass yield st =[c2]=> (X!-> st Y; st). Finally, (X!-> st Y; st) = (X!-> st X; st) = st = st. 11
13 The final rule is E_WhileTrue. Then beval st!(x=y) = true (so st X <> st Y) and we are given H: st=[x::=x.+1]=>st, H :st =[c1]=>st, and IH: st =[c2]=>st. By H, we know st = (X!->st X+1;st). Now, because c2 is an IFB command, st =[c2]=> st must have been derived in one of two ways: The final rule is E_IfTrue. Then st X <= st Y, and st =[X::=Y]=> st. Therefore, st = (X!-> Y; st ) = (X!-> Y; st). But we know that st X = st X + 1, and st Y = st Y, so by E_IfTrue, st =[c2]=> st. The final rule is E_IfFalse. Then st =[WHILE true DO SKIP END]=> st. But this is a contradiction, since we know that this program diverges on all inputs. 12
14 For Reference Total maps Definition total_map (A : Type) := string -> A. Definition t_empty {A : Type} (v : A) : total_map A := (fun _ => v). Definition t_update {A : Type} (m : total_map A) (x : string) (v : A) := (* eqb_string : string -> string -> bool *) fun x => if eqb_string x x then v else m x. Notation "x!-> v ; m" := (t_update m x v) Notation "a!-> x" := (t_update empty_st a x). Useful facts about maps Lemma t_apply_empty : forall (A : Type) (x : string) (v : A), (_!-> v) x = v. Lemma t_update_eq : forall (A : Type) (m : total_map A) x v, (x!-> v ; m) x = v. Lemma t_update_neq : forall (A : Type) (m : total_map A) x1 x2 v, x1 <> x2 -> (x1!-> v ; m) x2 = m x2. Lemma t_update_shadow : forall (A : Type) (m : total_map A) x v1 v2, (x!-> v2 ; x!-> v1 ; m) = (x!-> v2 ; m). Lemma t_update_same : forall (A : Type) (m : total_map A) x, (x!-> m x ; m) = m. Lemma t_update_permute : forall (A : Type) (m : total_map A) v1 v2 x1 x2, x2 <> x1 -> (x1!-> v1 ; x2!-> v2 ; m) = (x2!-> v2 ; x1!-> v1 ; m). 1
15 Formal definitions for Imp Syntax Inductive aexp : Type := ANum : nat -> aexp AId : string -> aexp APlus : aexp -> aexp -> aexp AMinus : aexp -> aexp -> aexp AMult : aexp -> aexp -> aexp. Inductive bexp : Type := BTrue : bexp BFalse : bexp BEq : aexp -> aexp -> bexp BLe : aexp -> aexp -> bexp BNot : bexp -> bexp BAnd : bexp -> bexp -> bexp. Inductive com : Type := CSkip : com CAss : string -> aexp -> com CSeq : com -> com -> com CIf : bexp -> com -> com -> com CWhile : bexp -> com -> com. Infix ".+" := APlus (at level 50). Infix ".-" := AMinus (at level 50). Infix ".*" := AMult (at level 40). Infix ".<=" := BLe (at level 70). Infix ".=" := BEq (at level 70). Infix ".&&" := BAnd (at level 80). Notation "! b" := (BNot b) (at level 60). Notation " SKIP " := CSkip. Notation "x ::= a" := (CAss x a). Notation "c1 ;; c2" := (CSeq c1 c2). Notation " WHILE b DO c END " := (CWhile b c). Notation " IFB b THEN c1 ELSE c2 FI " := (CIf b c1 c2). There are also implicit coercions from nat and string to aexp, and from bool to bexp. 2
16 Evaluation functions for expressions Definition state := total_map nat. Fixpoint aeval (st : state) (a : aexp) : nat := match a with ANum n => n AId x => st x APlus a1 a2 => (aeval st a1) + (aeval st a2) AMinus a1 a2 => (aeval st a1) - (aeval st a2) AMult a1 a2 => (aeval st a1) * (aeval st a2) end. Fixpoint beval (st : state) (b : bexp) : bool := match b with BTrue => true BFalse => false BEq a1 a2 => (aeval st a1) =? (aeval st a2) BLe a1 a2 => (aeval st a1) <=? (aeval st a2) BNot b1 => negb (beval st b1) BAnd b1 b2 => andb (beval st b1) (beval st b2) end. 3
17 Evaluation relation for commands Inductive ceval : com -> state -> state -> Prop := E_Skip : forall st, st =[ SKIP ]=> st E_Ass : forall st a1 n x, aeval st a1 = n -> st =[ x ::= a1 ]=> (x!-> n ; st) E_Seq : forall c1 c2 st st st, st =[ c1 ]=> st -> st =[ c2 ]=> st -> st =[ c1 ;; c2 ]=> st E_IfTrue : forall st st b c1 c2, beval st b = true -> st =[ c1 ]=> st -> st =[ IFB b THEN c1 ELSE c2 FI ]=> st E_IfFalse : forall st st b c1 c2, beval st b = false -> st =[ c2 ]=> st -> st =[ IFB b THEN c1 ELSE c2 FI ]=> st E_WhileFalse : forall b st c, beval st b = false -> st =[ WHILE b DO c END ]=> st E_WhileTrue : forall st st st b c, beval st b = true -> st =[ c ]=> st -> st =[ WHILE b DO c END ]=> st -> st =[ WHILE b DO c END ]=> st where "st =[ c ]=> st " := (ceval c st st ). Program equivalence Definition aequiv (a1 a2 : aexp) : Prop := forall (st : state), aeval st a1 = aeval st a2. Definition bequiv (b1 b2 : bexp) : Prop := forall (st : state), beval st b1 = beval st b2. Definition cequiv (c1 c2 : com) : Prop := forall (st st : state), (st =[ c1 ]=> st ) <-> (st =[ c2 ]=> st ). 4
18 Hoare triples Definition hoare_triple (P : Assertion) (c : com) (Q : Assertion) : Prop := forall st st, st =[ c ]=> st -> P st -> Q st. Notation "{{ P }} c {{ Q }}" := (hoare_triple P c Q). Implication on assertions Definition assert_implies (P Q : Assertion) : Prop := forall st, P st -> Q st. Notation "P ->> Q" := (assert_implies P Q). Hoare logic rules (ASCII ->> is typeset as a hollow arrow in the rules below.) { assn_sub x a Q } x := a { Q } (hoare_asgn) { P } SKIP { P } { P } c1 { Q } { Q } c2 { R } { P } c1;;c2 { R } (hoare_skip) (hoare_seq) { P b } c1 { Q } { P b } c2 { Q } { P } IFB b THEN c1 ELSE c2 FI { Q } (hoare_if) { P b } c { P } { P } WHILE b DO c END { P b } (hoare_while) { P } c { Q } P P { P } c { Q } { P } c { Q } Q Q { P } c { Q } (hoare_consequence_pre) (hoare_consequence_post) 5
19 Relations Definition relation (X : Type) := X -> X -> Prop. Inductive multi {X : Type} (R : relation X) : relation X := multi_refl : forall (x : X), multi R x x multi_step : forall (x y z : X), R x y -> multi R y z -> multi R x z. Notation " t -->* t " := (multi step t t ). Definition normal_form {X : Type} (R : relation X) (t : X) : Prop := ~ exists t, R t t. Lemmas for the multi-step relation Lemma multistep_congr_1 : forall t1 t1 t2, t1 -->* t1 -> P t1 t2 -->* P t1 t2. Lemma multistep_congr_2 : forall t1 t2 t2, value t1 -> t2 -->* t2 -> P t1 t2 -->* P t1 t2. Lemma multi_trans : forall (X:Type) (R: relation X) (x y z : X), multi R x y -> multi R y z -> multi R x z. 6
20 Small Step Semantics Small-step relation for arithmetic expressions Inductive astep : state -> aexp -> aexp -> Prop := AS_Id : forall st i, AId i / st -->a ANum (st i) AS_Plus1 : forall st a1 a1 a2, a1 / st -->a a1 -> (APlus a1 a2) / st -->a (APlus a1 a2) AS_Plus2 : forall st v1 a2 a2, aval v1 -> a2 / st -->a a2 -> (APlus v1 a2) / st -->a (APlus v1 a2 ) AS_Plus : forall st n1 n2, APlus (ANum n1) (ANum n2) / st -->a ANum (n1 + n2) AS_Minus1 : forall st a1 a1 a2, a1 / st -->a a1 -> (AMinus a1 a2) / st -->a (AMinus a1 a2) AS_Minus2 : forall st v1 a2 a2, aval v1 -> a2 / st -->a a2 -> (AMinus v1 a2) / st -->a (AMinus v1 a2 ) AS_Minus : forall st n1 n2, (AMinus (ANum n1) (ANum n2)) / st -->a (ANum (minus n1 n2)) AS_Mult1 : forall st a1 a1 a2, a1 / st -->a a1 -> (AMult a1 a2) / st -->a (AMult a1 a2) AS_Mult2 : forall st v1 a2 a2, aval v1 -> a2 / st -->a a2 -> (AMult v1 a2) / st -->a (AMult v1 a2 ) AS_Mult : forall st n1 n2, (AMult (ANum n1) (ANum n2)) / st -->a (ANum (mult n1 n2)) where " t / st -->a t " := (astep st t t ). 7
21 Small-step relation for boolean expressions Inductive bstep : state -> bexp -> bexp -> Prop := BS_Eq1 : forall st a1 a1 a2, a1 / st -->a a1 -> (BEq a1 a2) / st -->b (BEq a1 a2) BS_Eq2 : forall st v1 a2 a2, aval v1 -> a2 / st -->a a2 -> (BEq v1 a2) / st -->b (BEq v1 a2 ) BS_Eq : forall st n1 n2, (BEq (ANum n1) (ANum n2)) / st -->b (if (n1 =? n2) then BTrue else BFalse) BS_LtEq1 : forall st a1 a1 a2, a1 / st -->a a1 -> (BLe a1 a2) / st -->b (BLe a1 a2) BS_LtEq2 : forall st v1 a2 a2, aval v1 -> a2 / st -->a a2 -> (BLe v1 a2) / st -->b (BLe v1 a2 ) BS_LtEq : forall st n1 n2, (BLe (ANum n1) (ANum n2)) / st -->b (if (n1 <=? n2) then BTrue else BFalse) BS_NotStep : forall st b1 b1, b1 / st -->b b1 -> (BNot b1) / st -->b (BNot b1 ) BS_NotTrue : forall st, (BNot BTrue) / st -->b BFalse BS_NotFalse : forall st, (BNot BFalse) / st -->b BTrue BS_AndTrueStep : forall st b2 b2, b2 / st -->b b2 -> (BAnd BTrue b2) / st -->b (BAnd BTrue b2 ) BS_AndStep : forall st b1 b1 b2, b1 / st -->b b1 -> (BAnd b1 b2) / st -->b (BAnd b1 b2) BS_AndTrueTrue : forall st, (BAnd BTrue BTrue) / st -->b BTrue BS_AndTrueFalse : forall st, (BAnd BTrue BFalse) / st -->b BFalse BS_AndFalse : forall st b2, (BAnd BFalse b2) / st -->b BFalse where " t / st -->b t " := (bstep st t t ). 8
22 Small-step relation for Imp commands Inductive cstep : (com * state) -> (com * state) -> Prop := CS_AssStep : forall st i a a, a / st -->a a -> (i ::= a) / st --> (i ::= a ) / st CS_Ass : forall st i n, (i ::= (ANum n)) / st --> SKIP / (i!-> n ; st) CS_SeqStep : forall st c1 c1 st c2, c1 / st --> c1 / st -> (c1 ;; c2) / st --> (c1 ;; c2) / st CS_SeqFinish : forall st c2, (SKIP ;; c2) / st --> c2 / st CS_IfStep : forall st b b c1 c2, b / st -->b b -> IFB b THEN c1 ELSE c2 FI / st --> (IFB b THEN c1 ELSE c2 FI) / st CS_IfTrue : forall st c1 c2, IFB BTrue THEN c1 ELSE c2 FI / st --> c1 / st CS_IfFalse : forall st c1 c2, IFB BFalse THEN c1 ELSE c2 FI / st --> c2 / st CS_While : forall st b c1, WHILE b DO c1 END / st --> (IFB b THEN c1;; WHILE b DO c1 END ELSE SKIP FI) / st where " t / st --> t / st " := (cstep (t,st) (t,st )). 9
23 Simple expression language Inductive tm : Type := C : nat -> tm P : tm -> tm -> tm. Inductive value : tm -> Prop := v_const : forall n, value (C n). Big-step evaluation of tm Inductive eval : tm -> nat -> Prop := E_Const : forall n, C n ==> n E_Plus : forall t1 t2 n1 n2, t1 ==> n1 -> t2 ==> n2 -> P t1 t2 ==> (n1 + n2) where " t ==> n " := (eval t n). Small-step relation for tm Inductive step : tm -> tm -> Prop := ST_PlusConstConst : forall n1 n2, P (C n1) (C n2) --> C (n1 + n2) ST_Plus1 : forall t1 t1 t2, t1 --> t1 -> P t1 t2 --> P t1 t2 ST_Plus2 : forall n1 t2 t2, t2 --> t2 -> P (C n1) t2 --> P (C n1) t2 where " t --> t " := (step t t ). Theorem strong_progress : forall t, value t \/ (exists t, t --> t ). Minimum and maximum functions Definition min (a : nat) (b : nat) := if a <=? b then a else b. Definition max (a : nat) (b : nat) := if a <=? b then b else a. 10
CIS 500: Software Foundations
CIS 500: Software Foundations Midterm II November 8, 2016 Directions: This exam booklet contains both the standard and advanced track questions. Questions with no annotation are for both tracks. Other
More informationCIS 500 Software Foundations. Midterm II. March 28, 2012
CIS 500 Software Foundations Midterm II March 28, 2012 Name: Pennkey: Scores: 1 2 3 4 5 6 Total (80 max) This exam concentrates on the material on the Imp programming language, program equivalence, and
More informationCIS 500: Software Foundations
CIS 500: Software Foundations Solutions Final Exam December 15, 2017 1. Inductive relations (11 points) Complete the definition at the bottom of the page of an Inductive relation count that relates a list
More informationCIS 500 Software Foundations. Final Exam. May 9, Answer key. Hoare Logic
CIS 500 Software Foundations Final Exam May 9, 2011 Answer key Hoare Logic 1. (7 points) What does it mean to say that the Hoare triple {{P}} c {{Q}} is valid? Answer: {{P}} c {{Q}} means that, for any
More informationHoare Logic and Model Checking
Hoare Logic and Model Checking Kasper Svendsen University of Cambridge CST Part II 2016/17 Acknowledgement: slides heavily based on previous versions by Mike Gordon and Alan Mycroft Introduction In the
More informationHoare Examples & Proof Theory. COS 441 Slides 11
Hoare Examples & Proof Theory COS 441 Slides 11 The last several lectures: Agenda Denotational semantics of formulae in Haskell Reasoning using Hoare Logic This lecture: Exercises A further introduction
More informationCIS 500: Software Foundations
CIS 500: Software Foundations Midterm I October 3, 2017 Directions: This exam booklet contains both the standard and advanced track questions. Questions with no annotation are for both tracks. Other questions
More information0.1 Random useful facts. 0.2 Language Definition
0.1 Random useful facts Lemma double neg : P : Prop, {P} + { P} P P. Lemma leq dec : n m, {n m} + {n > m}. Lemma lt dec : n m, {n < m} + {n m}. 0.2 Language Definition Definition var := nat. Definition
More informationSemantics and Verification of Software
Semantics and Verification of Software Thomas Noll Software Modeling and Verification Group RWTH Aachen University http://moves.rwth-aachen.de/teaching/ss-15/sv-sw/ The Denotational Approach Denotational
More informationC241 Homework Assignment 7
C24 Homework Assignment 7. Prove that for all whole numbers n, n i 2 = n(n + (2n + The proof is by induction on k with hypothesis H(k i 2 = k(k + (2k + base case: To prove H(, i 2 = = = 2 3 = ( + (2 +
More informationAxiomatic Semantics. Lecture 9 CS 565 2/12/08
Axiomatic Semantics Lecture 9 CS 565 2/12/08 Axiomatic Semantics Operational semantics describes the meaning of programs in terms of the execution steps taken by an abstract machine Denotational semantics
More informationDenotational Semantics of Programs. : SimpleExp N.
Models of Computation, 2010 1 Denotational Semantics of Programs Denotational Semantics of SimpleExp We will define the denotational semantics of simple expressions using a function : SimpleExp N. Denotational
More informationHoare Logic: Part II
Hoare Logic: Part II COMP2600 Formal Methods for Software Engineering Jinbo Huang Australian National University COMP 2600 Hoare Logic II 1 Factorial {n 0} fact := 1; i := n; while (i >0) do fact := fact
More informationHoare Logic: Reasoning About Imperative Programs
Hoare Logic: Reasoning About Imperative Programs COMP1600 / COMP6260 Dirk Pattinson Australian National University Semester 2, 2018 Programming Paradigms Functional. (Haskell, SML, OCaml,... ) main paradigm:
More informationAxiomatic Semantics. Operational semantics. Good for. Not good for automatic reasoning about programs
Review Operational semantics relatively l simple many flavors (small vs. big) not compositional (rule for while) Good for describing language implementation reasoning about properties of the language eg.
More informationDynamic Semantics. Dynamic Semantics. Operational Semantics Axiomatic Semantics Denotational Semantic. Operational Semantics
Dynamic Semantics Operational Semantics Denotational Semantic Dynamic Semantics Operational Semantics Operational Semantics Describe meaning by executing program on machine Machine can be actual or simulated
More informationAxiomatic Semantics. Semantics of Programming Languages course. Joosep Rõõmusaare
Axiomatic Semantics Semantics of Programming Languages course Joosep Rõõmusaare 2014 Direct Proofs of Program Correctness Partial correctness properties are properties expressing that if a given program
More informationProof Calculus for Partial Correctness
Proof Calculus for Partial Correctness Bow-Yaw Wang Institute of Information Science Academia Sinica, Taiwan September 7, 2016 Bow-Yaw Wang (Academia Sinica) Proof Calculus for Partial Correctness September
More informationG54FOP: Lecture 17 & 18 Denotational Semantics and Domain Theory III & IV
G54FOP: Lecture 17 & 18 Denotational Semantics and Domain Theory III & IV Henrik Nilsson University of Nottingham, UK G54FOP: Lecture 17 & 18 p.1/33 These Two Lectures Revisit attempt to define denotational
More informationAxiomatic Semantics: Verification Conditions. Review of Soundness and Completeness of Axiomatic Semantics. Announcements
Axiomatic Semantics: Verification Conditions Meeting 12, CSCI 5535, Spring 2009 Announcements Homework 4 is due tonight Wed forum: papers on automated testing using symbolic execution 2 Questions? Review
More informationLearning Goals of CS245 Logic and Computation
Learning Goals of CS245 Logic and Computation Alice Gao April 27, 2018 Contents 1 Propositional Logic 2 2 Predicate Logic 4 3 Program Verification 6 4 Undecidability 7 1 1 Propositional Logic Introduction
More informationSoundness and Completeness of Axiomatic Semantics
#1 Soundness and Completeness of Axiomatic Semantics #2 One-Slide Summary A system of axiomatic semantics is sound if everything we can prove is also true: if ` { A } c { B } then ² { A } c { B } We prove
More informationStatic Program Analysis
Static Program Analysis Lecture 16: Abstract Interpretation VI (Counterexample-Guided Abstraction Refinement) Thomas Noll Lehrstuhl für Informatik 2 (Software Modeling and Verification) noll@cs.rwth-aachen.de
More informationLecture 2: Axiomatic semantics
Chair of Software Engineering Trusted Components Prof. Dr. Bertrand Meyer Lecture 2: Axiomatic semantics Reading assignment for next week Ariane paper and response (see course page) Axiomatic semantics
More informationSEMANTICS OF PROGRAMMING LANGUAGES Course Notes MC 308
University of Leicester SEMANTICS OF PROGRAMMING LANGUAGES Course Notes for MC 308 Dr. R. L. Crole Department of Mathematics and Computer Science Preface These notes are to accompany the module MC 308.
More informationArtificial Intelligence
Artificial Intelligence Propositional Logic [1] Boolean algebras by examples U X U U = {a} U = {a, b} U = {a, b, c} {a} {b} {a, b} {a, c} {b, c}... {a} {b} {c} {a, b} {a} The arrows represents proper inclusion
More informationAxiomatic Semantics. Stansifer Ch 2.4, Ch. 9 Winskel Ch.6 Slonneger and Kurtz Ch. 11 CSE
Axiomatic Semantics Stansifer Ch 2.4, Ch. 9 Winskel Ch.6 Slonneger and Kurtz Ch. 11 CSE 6341 1 Outline Introduction What are axiomatic semantics? First-order logic & assertions about states Results (triples)
More informationHoare Logic (I): Axiomatic Semantics and Program Correctness
Hoare Logic (I): Axiomatic Semantics and Program Correctness (Based on [Apt and Olderog 1991; Gries 1981; Hoare 1969; Kleymann 1999; Sethi 199]) Yih-Kuen Tsay Dept. of Information Management National Taiwan
More informationCIS (More Propositional Calculus - 6 points)
1 CIS6333 Homework 1 (due Friday, February 1) 1. (Propositional Calculus - 10 points) --------------------------------------- Let P, Q, R range over state predicates of some program. Prove or disprove
More informationIn this episode of The Verification Corner, Rustan Leino talks about Loop Invariants. He gives a brief summary of the theoretical foundations and
In this episode of The Verification Corner, Rustan Leino talks about Loop Invariants. He gives a brief summary of the theoretical foundations and shows how a program can sometimes be systematically constructed
More informationCS558 Programming Languages
CS558 Programming Languages Winter 2017 Lecture 2b Andrew Tolmach Portland State University 1994-2017 Semantics Informal vs. Formal Informal semantics Descriptions in English (or other natural language)
More informationVerifying Properties of Parallel Programs: An Axiomatic Approach
Verifying Properties of Parallel Programs: An Axiomatic Approach By Susan Owicki and David Gries (1976) Nathan Wetzler nwetzler@cs.utexas.edu University of Texas, Austin November 3, 2009 Outline Introduction
More informationSpring 2016 Program Analysis and Verification. Lecture 3: Axiomatic Semantics I. Roman Manevich Ben-Gurion University
Spring 2016 Program Analysis and Verification Lecture 3: Axiomatic Semantics I Roman Manevich Ben-Gurion University Warm-up exercises 1. Define program state: 2. Define structural semantics configurations:
More informationReasoning About Imperative Programs. COS 441 Slides 10b
Reasoning About Imperative Programs COS 441 Slides 10b Last time Hoare Logic: { P } C { Q } Agenda If P is true in the initial state s. And C in state s evaluates to s. Then Q must be true in s. Program
More informationCIS 500 Software Foundations Midterm II Answer key November 17, 2004
CIS 500 Software Foundations Midterm II Answer key November 17, 2004 Simply typed lambda-calculus The following questions refer to the simply typed lambda-calculus with booleans and error. The syntax,
More informationSolutions to exercises for the Hoare logic (based on material written by Mark Staples)
Solutions to exercises for the Hoare logic (based on material written by Mark Staples) Exercise 1 We are interested in termination, so that means we need to use the terminology of total correctness, i.e.
More informationAxiomatic Semantics: Verification Conditions. Review of Soundness of Axiomatic Semantics. Questions? Announcements
Axiomatic Semantics: Verification Conditions Meeting 18, CSCI 5535, Spring 2010 Announcements Homework 6 is due tonight Today s forum: papers on automated testing using symbolic execution Anyone looking
More informationCOP4020 Programming Languages. Introduction to Axiomatic Semantics Prof. Robert van Engelen
COP4020 Programming Languages Introduction to Axiomatic Semantics Prof. Robert van Engelen Assertions and Preconditions Assertions are used by programmers to verify run-time execution An assertion is a
More informationLecture Notes: Axiomatic Semantics and Hoare-style Verification
Lecture Notes: Axiomatic Semantics and Hoare-style Verification 17-355/17-665/17-819O: Program Analysis (Spring 2018) Claire Le Goues and Jonathan Aldrich clegoues@cs.cmu.edu, aldrich@cs.cmu.edu It has
More informationFoundations of Computation
The Australian National University Semester 2, 2018 Research School of Computer Science Tutorial 6 Dirk Pattinson Foundations of Computation The tutorial contains a number of exercises designed for the
More informationSpring 2015 Program Analysis and Verification. Lecture 4: Axiomatic Semantics I. Roman Manevich Ben-Gurion University
Spring 2015 Program Analysis and Verification Lecture 4: Axiomatic Semantics I Roman Manevich Ben-Gurion University Agenda Basic concepts of correctness Axiomatic semantics (pages 175-183) Hoare Logic
More informationHoare Logic: Reasoning About Imperative Programs
Hoare Logic: Reasoning About Imperative Programs COMP1600 / COMP6260 Dirk Pattinson Australian National University Semester 2, 2017 Catch Up / Drop in Lab When Fridays, 15.00-17.00 Where N335, CSIT Building
More informationDesign of Distributed Systems Melinda Tóth, Zoltán Horváth
Design of Distributed Systems Melinda Tóth, Zoltán Horváth Design of Distributed Systems Melinda Tóth, Zoltán Horváth Publication date 2014 Copyright 2014 Melinda Tóth, Zoltán Horváth Supported by TÁMOP-412A/1-11/1-2011-0052
More informationCSC 7101: Programming Language Structures 1. Axiomatic Semantics. Stansifer Ch 2.4, Ch. 9 Winskel Ch.6 Slonneger and Kurtz Ch. 11.
Axiomatic Semantics Stansifer Ch 2.4, Ch. 9 Winskel Ch.6 Slonneger and Kurtz Ch. 11 1 Overview We ll develop proof rules, such as: { I b } S { I } { I } while b do S end { I b } That allow us to verify
More informationHoare Logic I. Introduction to Deductive Program Verification. Simple Imperative Programming Language. Hoare Logic. Meaning of Hoare Triples
Hoare Logic I Introduction to Deductive Program Verification Işıl Dillig Program Spec Deductive verifier FOL formula Theorem prover valid contingent Example specs: safety (no crashes), absence of arithmetic
More informationThe Assignment Axiom (Hoare)
The Assignment Axiom (Hoare) Syntax: V := E Semantics: value of V in final state is value of E in initial state Example: X:=X+ (adds one to the value of the variable X) The Assignment Axiom {Q[E/V ]} V
More informationIntroduction to Axiomatic Semantics
#1 Introduction to Axiomatic Semantics #2 How s The Homework Going? Remember that you can t just define a meaning function in terms of itself you must use some fixed point machinery. #3 Observations A
More informationCSE 505, Fall 2009, Midterm Examination 5 November Please do not turn the page until everyone is ready.
CSE 505, Fall 2009, Midterm Examination 5 November 2009 Please do not turn the page until everyone is ready Rules: The exam is closed-book, closed-note, except for one side of one 85x11in piece of paper
More informationDeductive Verification
Deductive Verification Mooly Sagiv Slides from Zvonimir Rakamaric First-Order Logic A formal notation for mathematics, with expressions involving Propositional symbols Predicates Functions and constant
More information(2) (15pts) Using Prolog, implement a type-checker for the following small subset of System F:
CS 6371 Advanced Programming Languages Sample Spring 2018 Final Exam This sample final exam is LONGER than a real final exam (to give you more practice problems) and has a medium difficulty level. You
More informationProgramming Languages and Compilers (CS 421)
Programming Languages and Compilers (CS 421) Sasa Misailovic 4110 SC, UIUC https://courses.engr.illinois.edu/cs421/fa2017/cs421a Based in part on slides by Mattox Beckman, as updated by Vikram Adve, Gul
More informationDecidability: Church-Turing Thesis
Decidability: Church-Turing Thesis While there are a countably infinite number of languages that are described by TMs over some alphabet Σ, there are an uncountably infinite number that are not Are there
More informationLogic. Propositional Logic: Syntax
Logic Propositional Logic: Syntax Logic is a tool for formalizing reasoning. There are lots of different logics: probabilistic logic: for reasoning about probability temporal logic: for reasoning about
More informationPropositional Logic. CS 3234: Logic and Formal Systems. Martin Henz and Aquinas Hobor. August 26, Generated on Tuesday 31 August, 2010, 16:54
Propositional Logic CS 3234: Logic and Formal Systems Martin Henz and Aquinas Hobor August 26, 2010 Generated on Tuesday 31 August, 2010, 16:54 1 Motivation In traditional logic, terms represent sets,
More informationLogic. Propositional Logic: Syntax. Wffs
Logic Propositional Logic: Syntax Logic is a tool for formalizing reasoning. There are lots of different logics: probabilistic logic: for reasoning about probability temporal logic: for reasoning about
More informationPropositional Logic: Syntax
Logic Logic is a tool for formalizing reasoning. There are lots of different logics: probabilistic logic: for reasoning about probability temporal logic: for reasoning about time (and programs) epistemic
More informationSoftware Engineering
Software Engineering Lecture 07: Design by Contract Peter Thiemann University of Freiburg, Germany 02.06.2014 Table of Contents Design by Contract Contracts for Procedural Programs Contracts for Object-Oriented
More informationCS156: The Calculus of Computation Zohar Manna Autumn 2008
Page 3 of 52 Page 4 of 52 CS156: The Calculus of Computation Zohar Manna Autumn 2008 Lecturer: Zohar Manna (manna@cs.stanford.edu) Office Hours: MW 12:30-1:00 at Gates 481 TAs: Boyu Wang (wangboyu@stanford.edu)
More information2.7.1 Foundations of Proof Systems
2.7.1 Foundations of Proof Systems Exam 2017-2018 1 Warming up... Question 1 Give a proof in natural deduction of the following proposition : ( f = (g = h)) = (( f = g) = ( f = h)). Solution. f (g h);
More informationClassical Program Logics: Hoare Logic, Weakest Liberal Preconditions
Chapter 1 Classical Program Logics: Hoare Logic, Weakest Liberal Preconditions 1.1 The IMP Language IMP is a programming language with an extensible syntax that was developed in the late 1960s. We will
More informationCSE 505, Fall 2005, Midterm Examination 8 November Please do not turn the page until everyone is ready.
CSE 505, Fall 2005, Midterm Examination 8 November 2005 Please do not turn the page until everyone is ready. Rules: The exam is closed-book, closed-note, except for one side of one 8.5x11in piece of paper.
More informationTecniche di Verifica. Introduction to Propositional Logic
Tecniche di Verifica Introduction to Propositional Logic 1 Logic A formal logic is defined by its syntax and semantics. Syntax An alphabet is a set of symbols. A finite sequence of these symbols is called
More informationProgram verification. Hoare triples. Assertional semantics (cont) Example: Semantics of assignment. Assertional semantics of a program
Program verification Assertional semantics of a program Meaning of a program: relation between its inputs and outputs; specified by input assertions (pre-conditions) and output assertions (post-conditions)
More informationOn the Complexity of the Reflected Logic of Proofs
On the Complexity of the Reflected Logic of Proofs Nikolai V. Krupski Department of Math. Logic and the Theory of Algorithms, Faculty of Mechanics and Mathematics, Moscow State University, Moscow 119899,
More informationNormal Forms of Propositional Logic
Normal Forms of Propositional Logic Bow-Yaw Wang Institute of Information Science Academia Sinica, Taiwan September 12, 2017 Bow-Yaw Wang (Academia Sinica) Normal Forms of Propositional Logic September
More informationWhat happens to the value of the expression x + y every time we execute this loop? while x>0 do ( y := y+z ; x := x:= x z )
Starter Questions Feel free to discuss these with your neighbour: Consider two states s 1 and s 2 such that s 1, x := x + 1 s 2 If predicate P (x = y + 1) is true for s 2 then what does that tell us about
More informationMP 5 Program Transition Systems and Linear Temporal Logic
MP 5 Program Transition Systems and Linear Temporal Logic CS 477 Spring 2018 Revision 1.0 Assigned April 10, 2018 Due April 17, 2018, 9:00 PM Extension extend48 hours (penalty 20% of total points possible)
More information1. Propositions: Contrapositives and Converses
Preliminaries 1 1. Propositions: Contrapositives and Converses Given two propositions P and Q, the statement If P, then Q is interpreted as the statement that if the proposition P is true, then the statement
More informationWhy Learning Logic? Logic. Propositional Logic. Compound Propositions
Logic Objectives Propositions and compound propositions Negation, conjunction, disjunction, and exclusive or Implication and biconditional Logic equivalence and satisfiability Application of propositional
More informationUNIT-I: Propositional Logic
1. Introduction to Logic: UNIT-I: Propositional Logic Logic: logic comprises a (formal) language for making statements about objects and reasoning about properties of these objects. Statements in a logical
More informationCS156: The Calculus of Computation
CS156: The Calculus of Computation Zohar Manna Winter 2010 It is reasonable to hope that the relationship between computation and mathematical logic will be as fruitful in the next century as that between
More informationAutomated Program Verification and Testing 15414/15614 Fall 2016 Lecture 2: Propositional Logic
Automated Program Verification and Testing 15414/15614 Fall 2016 Lecture 2: Propositional Logic Matt Fredrikson mfredrik@cs.cmu.edu October 17, 2016 Matt Fredrikson Propositional Logic 1 / 33 Propositional
More informationLecture Notes on Inductive Definitions
Lecture Notes on Inductive Definitions 15-312: Foundations of Programming Languages Frank Pfenning Lecture 2 August 28, 2003 These supplementary notes review the notion of an inductive definition and give
More informationEDA045F: Program Analysis LECTURE 10: TYPES 1. Christoph Reichenbach
EDA045F: Program Analysis LECTURE 10: TYPES 1 Christoph Reichenbach In the last lecture... Performance Counters Challenges in Dynamic Performance Analysis Taint Analysis Binary Instrumentation 2 / 44 Types
More informationCS 6110 Lecture 21 The Fixed-Point Theorem 8 March 2013 Lecturer: Andrew Myers. 1 Complete partial orders (CPOs) 2 Least fixed points of functions
CS 6110 Lecture 21 The Fixed-Point Theorem 8 March 2013 Lecturer: Andrew Myers We saw that the semantics of the while command are a fixed point. We also saw that intuitively, the semantics are the limit
More informationLogical Agents. Knowledge based agents. Knowledge based agents. Knowledge based agents. The Wumpus World. Knowledge Bases 10/20/14
0/0/4 Knowledge based agents Logical Agents Agents need to be able to: Store information about their environment Update and reason about that information Russell and Norvig, chapter 7 Knowledge based agents
More informationProgram Analysis Part I : Sequential Programs
Program Analysis Part I : Sequential Programs IN5170/IN9170 Models of concurrency Program Analysis, lecture 5 Fall 2018 26. 9. 2018 2 / 44 Program correctness Is my program correct? Central question for
More informationUsing the Prover I: Lee Pike. June 3, NASA Langley Formal Methods Group Using the Prover I:
Basic Basic NASA Langley Formal Methods Group lee.s.pike@nasa.gov June 3, 2005 Basic Sequents Basic Sequent semantics: The conjunction of the antecedents above the turnstile implies the disjunction of
More informationDiscrete Math in Computer Science Solutions to Practice Problems for Midterm 2
Discrete Math in Computer Science Solutions to Practice Problems for Midterm 2 CS 30, Fall 2018 by Professor Prasad Jayanti Problems 1. Let g(0) = 2, g(1) = 1, and g(n) = 2g(n 1) + g(n 2) whenever n 2.
More informationLast Time. Inference Rules
Last Time When program S executes it switches to a different state We need to express assertions on the states of the program S before and after its execution We can do it using a Hoare triple written
More informationDynamic Noninterference Analysis Using Context Sensitive Static Analyses. Gurvan Le Guernic July 14, 2007
Dynamic Noninterference Analysis Using Context Sensitive Static Analyses Gurvan Le Guernic July 14, 2007 1 Abstract This report proposes a dynamic noninterference analysis for sequential programs. This
More informationINTRODUCTION TO LOGIC. Propositional Logic. Examples of syntactic claims
Introduction INTRODUCTION TO LOGIC 2 Syntax and Semantics of Propositional Logic Volker Halbach In what follows I look at some formal languages that are much simpler than English and define validity of
More informationCOMP2111 Glossary. Kai Engelhardt. Contents. 1 Symbols. 1 Symbols 1. 2 Hoare Logic 3. 3 Refinement Calculus 5. rational numbers Q, real numbers R.
COMP2111 Glossary Kai Engelhardt Revision: 1.3, May 18, 2018 Contents 1 Symbols 1 2 Hoare Logic 3 3 Refinement Calculus 5 1 Symbols Booleans B = {false, true}, natural numbers N = {0, 1, 2,...}, integers
More informationMid-Semester Quiz Second Semester, 2012
THE AUSTRALIAN NATIONAL UNIVERSITY Mid-Semester Quiz Second Semester, 2012 COMP2600 (Formal Methods for Software Engineering) Writing Period: 1 hour duration Study Period: 10 minutes duration Permitted
More informationA Short Introduction to Hoare Logic
A Short Introduction to Hoare Logic Supratik Chakraborty I.I.T. Bombay June 23, 2008 Supratik Chakraborty (I.I.T. Bombay) A Short Introduction to Hoare Logic June 23, 2008 1 / 34 Motivation Assertion checking
More informationInduction; Operational Semantics. Fall Software Foundations CIS 500
CIS 500 Software Foundations Fall 2005 Induction; Operational Semantics CIS 500, Induction; Operational Semantics 1 Announcements Review recitations start this week. You may go to any recitation section
More informationCSCI3390-Lecture 6: An Undecidable Problem
CSCI3390-Lecture 6: An Undecidable Problem September 21, 2018 1 Summary The language L T M recognized by the universal Turing machine is not decidable. Thus there is no algorithm that determines, yes or
More informationTruth-Functional Logic
Truth-Functional Logic Syntax Every atomic sentence (A, B, C, ) is a sentence and are sentences With ϕ a sentence, the negation ϕ is a sentence With ϕ and ψ sentences, the conjunction ϕ ψ is a sentence
More informationCS422 - Programming Language Design
1 CS422 - Programming Language Design Denotational Semantics Grigore Roşu Department of Computer Science University of Illinois at Urbana-Champaign 2 Denotational semantics, also known as fix-point semantics,
More informationCVO103: Programming Languages. Lecture 2 Inductive Definitions (2)
CVO103: Programming Languages Lecture 2 Inductive Definitions (2) Hakjoo Oh 2018 Spring Hakjoo Oh CVO103 2018 Spring, Lecture 2 March 13, 2018 1 / 20 Contents More examples of inductive definitions natural
More informationSupplementary Notes on Inductive Definitions
Supplementary Notes on Inductive Definitions 15-312: Foundations of Programming Languages Frank Pfenning Lecture 2 August 29, 2002 These supplementary notes review the notion of an inductive definition
More informationLecture Notes on Inductive Definitions
Lecture Notes on Inductive Definitions 15-312: Foundations of Programming Languages Frank Pfenning Lecture 2 September 2, 2004 These supplementary notes review the notion of an inductive definition and
More informationSection 7.1 Relations and Their Properties. Definition: A binary relation R from a set A to a set B is a subset R A B.
Section 7.1 Relations and Their Properties Definition: A binary relation R from a set A to a set B is a subset R A B. Note: there are no constraints on relations as there are on functions. We have a common
More informationProgramming Languages and Types
Programming Languages and Types Klaus Ostermann based on slides by Benjamin C. Pierce Where we re going Type Systems... Type systems are one of the most fascinating and powerful aspects of programming
More informationReview. Principles of Programming Languages. Equality. The Diamond Property. The Church-Rosser Theorem. Corollaries. CSE 230: Winter 2007
CSE 230: Winter 2007 Principles of Programming Languages Lecture 12: The λ-calculus Ranjit Jhala UC San Diego Review The lambda calculus is a calculus of functions: e := x λx. e e 1 e 2 Several evaluation
More informationProgram verification. 18 October 2017
Program verification 18 October 2017 Example revisited // assume(n>2); void partition(int a[], int n) { int pivot = a[0]; int lo = 1, hi = n-1; while (lo
More informationPropositional Logic: Part II - Syntax & Proofs 0-0
Propositional Logic: Part II - Syntax & Proofs 0-0 Outline Syntax of Propositional Formulas Motivating Proofs Syntactic Entailment and Proofs Proof Rules for Natural Deduction Axioms, theories and theorems
More informationLimits and Continuity
Chapter Limits and Continuity. Limits of Sequences.. The Concept of Limit and Its Properties A sequence { } is an ordered infinite list x,x,...,,... The n-th term of the sequence is, and n is the index
More informationFormal Reasoning CSE 331. Lecture 2 Formal Reasoning. Announcements. Formalization and Reasoning. Software Design and Implementation
CSE 331 Software Design and Implementation Lecture 2 Formal Reasoning Announcements Homework 0 due Friday at 5 PM Heads up: no late days for this one! Homework 1 due Wednesday at 11 PM Using program logic
More informationIntroduction to Metalogic
Philosophy 135 Spring 2008 Tony Martin Introduction to Metalogic 1 The semantics of sentential logic. The language L of sentential logic. Symbols of L: Remarks: (i) sentence letters p 0, p 1, p 2,... (ii)
More information