15-819M: Data, Code, Decisions

Size: px
Start display at page:

Download "15-819M: Data, Code, Decisions"

Transcription

1 15-819M: Data, Code, Decisions 08: First-Order Logic André Platzer Carnegie Mellon University, Pittsburgh, PA André Platzer (CMU) M/08: Data, Code, Decisions 1 / 40

2 Outline 1 Formal Modeling 2 First-Order Logic Signature Terms Formulas 3 Semantics Domain Model Variable Assignment Term Valuation Formula Valuation Semantic Notions 4 Untyped Logic 5 Modeling with FOL 6 Summary André Platzer (CMU) M/08: Data, Code, Decisions 1 / 40

3 Outline 1 Formal Modeling 2 First-Order Logic Signature Terms Formulas 3 Semantics Domain Model Variable Assignment Term Valuation Formula Valuation Semantic Notions 4 Untyped Logic 5 Modeling with FOL 6 Summary André Platzer (CMU) M/08: Data, Code, Decisions 1 / 40

4 Formalisation Real World Formalisation Formal Model André Platzer (CMU) M/08: Data, Code, Decisions 2 / 40

5 Formalisation: Syntax, Semantics Syntax Formal Language Real World Semantics Formal Semantics André Platzer (CMU) M/08: Data, Code, Decisions 2 / 40

6 Formalisation: Syntax, Semantics Real World Syntax Semantics Formal Language Interpretation Formal Semantics André Platzer (CMU) M/08: Data, Code, Decisions 2 / 40

7 Formalisation: Syntax, Semantics Real World Syntax Propositional Logic Interpretation Semantics Valuation André Platzer (CMU) M/08: Data, Code, Decisions 2 / 40

8 Formalisation: Syntax, Semantics Real World Syntax First-Order Logic Interpretation Semantics Valuation André Platzer (CMU) M/08: Data, Code, Decisions 2 / 40

9 Approaches to Formal Software Verification KeY Concrete programs, Complex properties Abstract programs, Complex properties Concrete programs, Simple properties Abstract programs, Simple properties Spin André Platzer (CMU) M/08: Data, Code, Decisions 3 / 40

10 Formal Verification: Deduction Syntax Translation Java+ JML Dynamic Logic Real World Semantics Kripke Semantics Sequent Calculus André Platzer (CMU) M/08: Data, Code, Decisions 4 / 40

11 Beyond Propositional Logic Propositional Logic +functions +state change First-order Logic Temporal Logic André Platzer (CMU) M/08: Data, Code, Decisions 5 / 40

12 Beyond Propositional Logic Propositional Logic +functions First-order Logic +state change +functions Dynamic Logic +state change Temporal Logic André Platzer (CMU) M/08: Data, Code, Decisions 5 / 40

13 Beyond Propositional Logic Propositional Logic +functions First-order Logic +state change +functions Dynamic Logic +state change Temporal Logic Spin André Platzer (CMU) M/08: Data, Code, Decisions 5 / 40

14 Beyond Propositional Logic Propositional Logic +functions First-order Logic +state change +functions Dynamic Logic KeY +state change Temporal Logic Spin André Platzer (CMU) M/08: Data, Code, Decisions 5 / 40

15 Beyond Propositional Logic today s lecture Propositional Logic +functions First-order Logic +state change +functions Dynamic Logic KeY +state change Temporal Logic Spin André Platzer (CMU) M/08: Data, Code, Decisions 5 / 40

16 Syntax, Semantics, Calculus Syntax Formula/Program x Semantics valid Calculus Derivable André Platzer (CMU) M/08: Data, Code, Decisions 6 / 40

17 Syntax, Semantics, Calculus Syntax Formula/Program x Completeness Semantics valid Calculus Derivable André Platzer (CMU) M/08: Data, Code, Decisions 6 / 40

18 Syntax, Semantics, Calculus Syntax Formula/Program x Completeness Semantics valid Soundness Calculus Derivable André Platzer (CMU) M/08: Data, Code, Decisions 6 / 40

19 Limitations of Propositional Logic Fixed, finite number of objects Cannot express: let g be group with arbitrary number of elements No functions or relations with arguments Can express: finite function/relation table with indexed variables p ij Cannot express: properties of function/relation on all arguments: + associative Static interpretation Programs change value of their variables, e.g., via assignment, call, etc. Propositional formulas look at one single interpretation at a time André Platzer (CMU) M/08: Data, Code, Decisions 7 / 40

20 Outline 1 Formal Modeling 2 First-Order Logic Signature Terms Formulas 3 Semantics Domain Model Variable Assignment Term Valuation Formula Valuation Semantic Notions 4 Untyped Logic 5 Modeling with FOL 6 Summary André Platzer (CMU) M/08: Data, Code, Decisions 7 / 40

21 Propositional Logic Propositional Formulas x = Mapping Var {T, F } Sequent Calculus André Platzer (CMU) M/08: Data, Code, Decisions 8 / 40

22 First-Order Logic First-Order Formulas x = First-Order Model Sequent Calculus André Platzer (CMU) M/08: Data, Code, Decisions 8 / 40

23 Syntax of First-Order Logic: Signature Definition (First-Order Signature) First-order signature Σ = (PSym, FSym, α) Predicate or Relation Symbols PSym = {p i i IIN} Function Symbols FSym = {f i i IIN} Typing function α, set of types T α(p) T for all p PSym α(f ) T T for all f FSym Definition (Variables) VSym = {x i i IIN} set of typed variables In contrast to standard FOL, our symbols are typed Necessary to model a typed programming language such as Java! Allow any non-reserved name for symbols, not merely p 3, f 17,... André Platzer (CMU) M/08: Data, Code, Decisions 9 / 40

24 Syntax of First-Order Logic: Signature Declaration of signature symbols Write T x; to declare variable x of type T Write p(t 1,..., T r ); for α(p) = (T 1,..., T r ) Write T f (T 1,..., T r ); for α(f ) = ((T 1,..., T r ), T ) Similar convention as in Java, no overloading of symbols Case r = 0 is allowed, then write p instead of p(), etc. André Platzer (CMU) M/08: Data, Code, Decisions 10 / 40

25 Syntax of First-Order Logic: Signature Declaration of signature symbols Write T x; to declare variable x of type T Write p(t 1,..., T r ); for α(p) = (T 1,..., T r ) Write T f (T 1,..., T r ); for α(f ) = ((T 1,..., T r ), T ) Similar convention as in Java, no overloading of symbols Case r = 0 is allowed, then write p instead of p(), etc. Example Variables boolean b; int i; Predicates isempty(list); alerton; Functions int arraylookup(int); java.lang.object o; André Platzer (CMU) M/08: Data, Code, Decisions 10 / 40

26 OO Type Hierarchy We want to model the behavior of Java programs Admissible types T form object-oriented type hierarchy André Platzer (CMU) M/08: Data, Code, Decisions 11 / 40

27 OO Type Hierarchy We want to model the behavior of Java programs Admissible types T form object-oriented type hierarchy Definition (OO Type Hierarchy) T is finite set of types (not parameterized) Given subtype relation, assume T has all supertypes, i.e., T is -closed Dynamic types T d T, where T d Abstract types T a T, where T a T d T a = T d T a = T T for all T T André Platzer (CMU) M/08: Data, Code, Decisions 11 / 40

28 OO Type Hierarchy Example Using UML notation Object AbstractCollection List int AbstractList ArrayList Null André Platzer (CMU) M/08: Data, Code, Decisions 12 / 40

29 OO Type Hierarchy Dynamic types are those with direct elements Abstract types for abstract classes and interfaces Java 1.5+ is -closed In Java primitive (value) and object types incomparable is abstract and hence no object ever can have this type cannot occur in declaration of signature symbols Each abstract type except has a non-empty dynamic subtype In Java is chosen to have no direct elements Java has infinitely many types: int[], int[][],... Restrict T to the finitely many types that occur in a given program André Platzer (CMU) M/08: Data, Code, Decisions 13 / 40

30 OO Type Hierarchy Dynamic types are those with direct elements Abstract types for abstract classes and interfaces Java 1.5+ is -closed In Java primitive (value) and object types incomparable is abstract and hence no object ever can have this type cannot occur in declaration of signature symbols Each abstract type except has a non-empty dynamic subtype In Java is chosen to have no direct elements Java has infinitely many types: int[], int[][],... Restrict T to the finitely many types that occur in a given program Example (The Minimal Type Hierarchy) T = {, } All signature symbols have same type : drop type, untyped logic André Platzer (CMU) M/08: Data, Code, Decisions 13 / 40

31 Reserved Signature Symbols Reserved signature symbols. Equality symbol = PSym declared as =. (, ) Written infix: x. = 0 Type predicate symbol T PSym for each T T Declared as T ( ) Written prefix: i int read instance of Type cast symbol (T ) FSym for each T T Declared as T (T )( ) Written prefix: (String)o read cast o to String André Platzer (CMU) M/08: Data, Code, Decisions 14 / 40

32 Reserved Signature Symbols Reserved signature symbols. Equality symbol = PSym declared as =. (, ) Written infix: x. = 0 Type predicate symbol T PSym for each T T Declared as T ( ) Written prefix: i int read instance of Type cast symbol (T ) FSym for each T T Declared as T (T )( ) Written prefix: (String)o read cast o to String So far, we have a type system and a signature where is the logic? André Platzer (CMU) M/08: Data, Code, Decisions 14 / 40

33 Terms First-order terms, informally Think of first-order terms as expressions in a programming language Built up from variables, constants, function symbols First-order terms have no side effects (like Promela, unlike Java) First-order terms have a type and must respect type hierarchy type of f (g(x)) is result type in declaration of function f in f (g(x)) the result type of g is subtype of argument type of f, etc. André Platzer (CMU) M/08: Data, Code, Decisions 15 / 40

34 Terms First-order terms, informally Think of first-order terms as expressions in a programming language Built up from variables, constants, function symbols First-order terms have no side effects (like Promela, unlike Java) First-order terms have a type and must respect type hierarchy type of f (g(x)) is result type in declaration of function f in f (g(x)) the result type of g is subtype of argument type of f, etc. Definition (First-Order Terms {Term T } T T with type T T ) x is term of type T for variable declared as T x; f (t 1,..., t r ) is term of type T for function symbol declared as T f (T 1,..., T r ); and terms t i of type T i T i for 1 i r There are no other terms (inductive definition) André Platzer (CMU) M/08: Data, Code, Decisions 15 / 40

35 Terms Example Signature: int i; short j; List l; int f(int); f(i) has result type int and is contained in Term int f(j) has result type int (when short int) f(l) is ill-typed (when int, List incomparable) f(i,i) is not a term (doesn t match declaration) (int)j is term of type int even (int)l is term of type int (type cast always well-formed) André Platzer (CMU) M/08: Data, Code, Decisions 16 / 40

36 Terms Example Signature: int i; short j; List l; int f(int); f(i) has result type int and is contained in Term int f(j) has result type int (when short int) f(l) is ill-typed (when int, List incomparable) f(i,i) is not a term (doesn t match declaration) (int)j is term of type int even (int)l is term of type int (type cast always well-formed) If f is constant (r = 0) write f instead of f () Use infix notation liberally, where appropriate: declare int +(int, int); then write i+j, etc. Use brackets to disambiguiate parsing: (i+j)*i André Platzer (CMU) M/08: Data, Code, Decisions 16 / 40

37 First-Order Atomic Formulas Definition (Atomic First-Order Formulas) p(t 1,..., t r ) is atomic first-order formula for predicate symbol declared as p(t 1,..., T r ); and terms t i of type T i T i for 1 i r André Platzer (CMU) M/08: Data, Code, Decisions 17 / 40

38 First-Order Atomic Formulas Definition (Atomic First-Order Formulas) p(t 1,..., t r ) is atomic first-order formula for predicate symbol declared as p(t 1,..., T r ); and terms t i of type T i T i for 1 i r Example Signature: int i; short j; List l; <(int, int); i < i is an atomic first-order formula i < j is an atomic first-order formula (when short int) i < l is ill-typed (when int, List incomparable) i =j. and even i =l. are atomic first-order formulas i short is an atomic first-order formula André Platzer (CMU) M/08: Data, Code, Decisions 17 / 40

39 First-Order Formulas Definition (Set of First-Order Formulas For) Truth constants true, false and all first-order atomic formulas are first-order formulas If φ and ψ are first-order formulas then! φ, (φ & ψ), (φ ψ), (φ > ψ), (φ < > ψ) are also first-order formulas If T x is a variable declaration, φ a first-order formula, then T x; φ and T x; φ are first-order formulas Any occurrence of x in φ must be well-typed T x; φ called universally quantified formula T x; φ called existentially quantified formula André Platzer (CMU) M/08: Data, Code, Decisions 18 / 40

40 First-Order Formulas In T x; φ and T x; φ call φ the scope of x bound by / Variables bound in quantified formulas similar to program locations declared as local variables/formal parameters Example int i; int j; i < j is a first-order formula int i; List l; i < l is ill-typed int i; i < j is a first-order formula if j is a constant compatible with int ( int i; int j; i < j) ( int i; int j; i > j) is a first-order formula André Platzer (CMU) M/08: Data, Code, Decisions 19 / 40

41 Remark on Concrete Syntax Text book Spin KeY Java Negation!!! Conjunction && & && Disjunction Implication, > > n/a Equivalence < > < > n/a Universal Quantifier x; φ n/a \forall T x; φ n/a Existential Quantifier x; φ n/a \exists T x; φ n/a. Value equality = == = == André Platzer (CMU) M/08: Data, Code, Decisions 20 / 40

42 Remark on Concrete Syntax Text book Spin KeY Java Negation!!! Conjunction && & && Disjunction Implication, > > n/a Equivalence < > < > n/a Universal Quantifier x; φ n/a \forall T x; φ n/a Existential Quantifier x; φ n/a \exists T x; φ n/a. Value equality = == = == For quantifiers we normally use textbook syntax and suppress type information to ease readability For propositional connectives we use KeY syntax André Platzer (CMU) M/08: Data, Code, Decisions 20 / 40

43 Outline 1 Formal Modeling 2 First-Order Logic Signature Terms Formulas 3 Semantics Domain Model Variable Assignment Term Valuation Formula Valuation Semantic Notions 4 Untyped Logic 5 Modeling with FOL 6 Summary André Platzer (CMU) M/08: Data, Code, Decisions 20 / 40

44 First-Order Semantics First-Order Formulas x = First-Order Model Sequent Calculus André Platzer (CMU) M/08: Data, Code, Decisions 21 / 40

45 First-Order Semantics First-Order Formulas x = First-Order Model Sequent Calculus André Platzer (CMU) M/08: Data, Code, Decisions 21 / 40

46 First-Order Semantics From propositional to first-order semantics In prop. logic, interpretation of variables with {T, F } In first-order logic we must assign meaning to: variables bound in quantifiers constant and function symbols predicate symbols Each variable or function value may denote a different object Respect typing: int i, List l must denote different objects What we need (to interpret a first-order formula) 1 A collection of typed universes of objects (akin to heap objects) 2 A mapping from variables to objects 3 A mapping from function arguments to function values 4 The set of argument tuples where a predicate is true André Platzer (CMU) M/08: Data, Code, Decisions 22 / 40

47 First-Order Domains/Universes 1 A collection of typed universes of objects Definition (Universe/Domain) A non-empty set D of objects is a universe or domain Each element of D has a fixed type given by δ : D T d Like heap objects and values in Java Notation for the domain elements type-compatible with T T : D T = {d D δ(d) T } For each dynamic type T T d there must be at least one domain element type-compatible with it: D T André Platzer (CMU) M/08: Data, Code, Decisions 23 / 40

48 First-Order Universes Example int short Object D = {17, o} δ(17) = short, δ(o) = Object Then D short = D int = {17}, D Object = {o}, D = D = {17, o}, and D = {} André Platzer (CMU) M/08: Data, Code, Decisions 24 / 40

49 First-Order Models 3 A mapping from function arguments to function values 4 The set of argument tuples where a predicate is true Definition (First-Order Model) Let D be a domain with typing function δ Let f be declared as T f (T 1,..., T r ); Let p be declared as p(t 1,..., T r ); Let I(f ) : D T 1 D Tr D T Let I(p) D T 1 D Tr Then M = (D, δ, I) is a first-order model André Platzer (CMU) M/08: Data, Code, Decisions 25 / 40

50 First-Order Models Example Signature: int i; short j; int f(int); Object obj; <(int,int); D = {17, 2, o} where all numbers are short I(i) = 17 I(j) = 17 I(obj) = o D int I(f ) D int D int in I(<)? (2, 2) F (2, 17) T (17, 2) F (17, 17) F One of uncountably many possible first-order models! André Platzer (CMU) M/08: Data, Code, Decisions 26 / 40

51 Semantics of Reserved Signature Symbols Definition Equality symbol. = declared as. = (, ) Model is fixed as I(. =) = {(d, d) d D} Referential Equality (holds if arguments refer to identical object) Exercise: write down the predicate table for example domain Type predicate symbol T for any T, declared as T ( ) I( T ) = D T Exercise: what is I( Object)? Type cast symbol (T ) for each T, declared as T (T )( ) { x if cast succeeds (δ(x) T ) I((T ))(x) = d otherwise, for an arbitrary fixed d D T Exercise: what is I((int))(17)? André Platzer (CMU) M/08: Data, Code, Decisions 27 / 40

52 Signature Symbols vs. Domain Elements Example Domain elements are not just the terms representing them First-order formulas and terms have no access to domain As in Java: identity and memory layout of values/objects hidden Think of a first-order model as a heap of first-order logic Signature: Object obj1, obj2; Domain: D = {o} In this model, necessarily I(obj1) = I(obj2) = o Effect similar to aliasing in Java with reference types André Platzer (CMU) M/08: Data, Code, Decisions 28 / 40

53 Variable Assignments 2 A mapping from variables to objects Think of variable assignment as environment for storage of local variables Definition (Variable Assignment) A variable assignment β maps variables to domain elements It respects the variable type, i.e., if x has type T then β(x) D T Definition (Modified Variable Assignment) Let y be variable of type T, β variable assignment, d D T : { βy d β(x) if x y (x) := d if x = y André Platzer (CMU) M/08: Data, Code, Decisions 29 / 40

54 Semantic Evaluation of Terms Given a first-order model M and a variable assignment β it is possible to evaluate first-order terms under M and β Analogy Evaluating an expression in a programming language with respect to a given heap (M) and binding of local variables (β) Definition (Valuation of Terms) val M,β : Term D such that val M,β (t) D T for t Term T : val M,β (x) = β(x) (recall that β respects typing) val M,β (f (t 1,..., t r )) = I(f )(val M,β (t 1 ),..., val M,β (t r )) André Platzer (CMU) M/08: Data, Code, Decisions 30 / 40

55 Semantic Evaluation of Terms Example Signature: int i; short j; int f(int); D = {17, 2, o} where all numbers are short Variables: Object obj; int x; I(i) = 17 I(j) = 17 D int I(f) Var β obj o x 17 val M,β (f(f(i)))? val M,β (x)? val M,β ((int)obj)? André Platzer (CMU) M/08: Data, Code, Decisions 31 / 40

56 Semantic Evaluation of Terms Example Signature: int i; short j; int f(int); D = {17, 2, o} where all numbers are short Variables: Object obj; int x; I(i) = 17 I(j) = 17 D int I(f) Var β obj o x 17 val M,β (f(f(i)))? = 17 val M,β (x)? val M,β ((int)obj)? André Platzer (CMU) M/08: Data, Code, Decisions 31 / 40

57 Semantic Evaluation of Terms Example Signature: int i; short j; int f(int); D = {17, 2, o} where all numbers are short Variables: Object obj; int x; I(i) = 17 I(j) = 17 D int I(f) Var β obj o x 17 val M,β (f(f(i)))? = 17 val M,β (x)? = 17 val M,β ((int)obj)? André Platzer (CMU) M/08: Data, Code, Decisions 31 / 40

58 Semantic Evaluation of Terms Example Signature: int i; short j; int f(int); D = {17, 2, o} where all numbers are short Variables: Object obj; int x; I(i) = 17 I(j) = 17 D int I(f) Var β obj o x 17 val M,β (f(f(i)))? = 17 val M,β (x)? = 17 val M,β ((int)obj)? = 2, say André Platzer (CMU) M/08: Data, Code, Decisions 31 / 40

59 Semantic Evaluation of Formulas Formulas are true or false A validity relation is more convenient than a function Definition (Validity Relation for Formulas) M, β = φ for φ For M, β models φ M, β = p(t 1,..., t r ) iff (val M,β (t 1 ),..., val M,β (t r )) I(p) M, β = φ & ψ iff M, β = φ and M, β = ψ... as in propositional logic M, β = T x; φ iff M, βx d = φ for all d D T M, β = T x; φ iff M, βx d = φ for at least one d D T André Platzer (CMU) M/08: Data, Code, Decisions 32 / 40

60 Semantic Evaluation of Formulas Example Signature: short j; int f(int); Object obj; <(int,int); D = {17, 2, o} where all numbers are short I(j) = 17 I(obj) = o D int I(f ) D int D int in I(<)? (2, 2) F (2, 17) T (17, 2) F (17, 17) F M, β = f (j) < j? M, β = int x; f (x). = x? M, β = Object o1; Object o2; o1. = o2? André Platzer (CMU) M/08: Data, Code, Decisions 33 / 40

61 Semantic Notions Definition (Satisfiability, Truth, Validity) M, β = φ (φ is satisfiable) M = φ iff for all β : M, β = φ (φ is true in M) = φ iff for all M : M = φ (φ is valid) Closed formulas that are satisfiable are also true: one top-level notion André Platzer (CMU) M/08: Data, Code, Decisions 34 / 40

62 Semantic Notions Definition (Satisfiability, Truth, Validity) M, β = φ (φ is satisfiable) M = φ iff for all β : M, β = φ (φ is true in M) = φ iff for all M : M = φ (φ is valid) Closed formulas that are satisfiable are also true: one top-level notion Example f (j) < j is true in M. int x; i = x is valid int x;!(x. = x) is not satisfiable André Platzer (CMU) M/08: Data, Code, Decisions 34 / 40

63 Outline 1 Formal Modeling 2 First-Order Logic Signature Terms Formulas 3 Semantics Domain Model Variable Assignment Term Valuation Formula Valuation Semantic Notions 4 Untyped Logic 5 Modeling with FOL 6 Summary André Platzer (CMU) M/08: Data, Code, Decisions 34 / 40

64 Untyped First-Order Logic Most logic textbooks introduce untyped logic How to obtain untyped logic as a special case Minimal Type Hierarchy: T = {, } D = D : only one populated type, drop all typing info Signature merely specifies arity of functions and predicates: Write f /1, < /2, i/0, etc. Untyped logic is suitable whenever we model a uniform domain Typical applications: pure mathematics such as algebra André Platzer (CMU) M/08: Data, Code, Decisions 35 / 40

65 Untyped First-Order Logic Example (Axiomatization of a group in first-order logic) Signature Σ G : FSym = { /2, e/0}, PSym = {. = /2} Let G be the following formulas: Left identity x; e x =. x Left inverse x; y; y x =. e Associativity x; y; z; (x y) z =. x (y z) Let φ be Σ G -formula. Whenever = G > φ, then φ is a theorem of group theory André Platzer (CMU) M/08: Data, Code, Decisions 36 / 40

66 Outline 1 Formal Modeling 2 First-Order Logic Signature Terms Formulas 3 Semantics Domain Model Variable Assignment Term Valuation Formula Valuation Semantic Notions 4 Untyped Logic 5 Modeling with FOL 6 Summary André Platzer (CMU) M/08: Data, Code, Decisions 36 / 40

67 Modeling with First-Order Logic First-Order Formulas Which? First-Order Models André Platzer (CMU) M/08: Data, Code, Decisions 37 / 40

68 Modeling with First-Order Logic First-Order Formulas Which? Example (At least two elements) First-Order Models André Platzer (CMU) M/08: Data, Code, Decisions 37 / 40

69 Modeling with First-Order Logic First-Order Formulas Which? Example (At least two elements) x; y;!(x. = y) How to do this without built-in equality? First-Order Models André Platzer (CMU) M/08: Data, Code, Decisions 37 / 40

70 Modeling with First-Order Logic First-Order Formulas Example (Strict partial order) Which? First-Order Models André Platzer (CMU) M/08: Data, Code, Decisions 37 / 40

71 Modeling with First-Order Logic First-Order Formulas First-Order Models Which? Example (Strict partial order) PSym = {< /2} Irreflexivity x;!(x < x) Asymmetry x; y; (x < y >!(y < x)) Transitivity x; y; z; (x < y & y < z > x < z) André Platzer (CMU) M/08: Data, Code, Decisions 37 / 40

72 Modeling with First-Order Logic First-Order Formulas Which? Example (All models have infinite domain) First-Order Models André Platzer (CMU) M/08: Data, Code, Decisions 37 / 40

73 Modeling with First-Order Logic First-Order Formulas Which? Example (All models have infinite domain) Signature and axioms of irreflexive order plus Existence Successor x; y; x < y First-Order Models André Platzer (CMU) M/08: Data, Code, Decisions 37 / 40

74 Modeling with First-Order Logic First-Order Formulas Which? Example (Abstract data types) FSym = { Stack push(int, Stack); int pop(stack); Stack nil; } First-Order Models int i; Stack s; pop(push(i, s)). = s André Platzer (CMU) M/08: Data, Code, Decisions 37 / 40

75 Why such a Complicated First-Order Semantics? Why not take terms and properties at their face value? Definition (Herbrand Model (untyped logic)) A first-order model where Domain D are all variable-free (i.e., ground) terms Each domain element is represented as a term Interpretation of function symbols is identity: I(f )(d 1,..., d r ) = f (d 1,..., d r ) André Platzer (CMU) M/08: Data, Code, Decisions 38 / 40

76 Why such a Complicated First-Order Semantics? Why not take terms and properties at their face value? Definition (Herbrand Model (untyped logic)) A first-order model where Domain D are all variable-free (i.e., ground) terms Each domain element is represented as a term Interpretation of function symbols is identity: I(f )(d 1,..., d r ) = f (d 1,..., d r ) Major limitations of Herbrand models Too many different domain elements: 1 + 2, Natural to represent program locations as terms and domain elements as their values whose exact representation we don t know There are theoretical limitations as well André Platzer (CMU) M/08: Data, Code, Decisions 38 / 40

77 Outline 1 Formal Modeling 2 First-Order Logic Signature Terms Formulas 3 Semantics Domain Model Variable Assignment Term Valuation Formula Valuation Semantic Notions 4 Untyped Logic 5 Modeling with FOL 6 Summary André Platzer (CMU) M/08: Data, Code, Decisions 38 / 40

78 Summary and Outlook Summary First-order formulas defined over a signature of typed symbols Hierarchical OO type system with abstract and dynamic types Quantification over variables, no free variables in formulas Semantic domain like objects in a Java heap First-order model assigns semantic value to terms and formulas Semantic notions satisfiability and validity André Platzer (CMU) M/08: Data, Code, Decisions 39 / 40

79 Summary and Outlook Summary First-order formulas defined over a signature of typed symbols Hierarchical OO type system with abstract and dynamic types Quantification over variables, no free variables in formulas Semantic domain like objects in a Java heap First-order model assigns semantic value to terms and formulas Semantic notions satisfiability and validity Semantic evaluation is not feasible in practice Infinite (uncountable) number of first-order models Evaluation of quantified formula may involve infinitely many cases Next goal: a syntactic calculus allowing mechanical validity checking André Platzer (CMU) M/08: Data, Code, Decisions 39 / 40

80 Background Literature KeYbook B. Beckert, R. Hähnle, and P. Schmitt, editors. Verification of Object-Oriented Software: The KeY Approach, vol 4334 of LNCS. Springer, Chapter 2: First-Order Logic Fitting Melvin Fitting. First-Order Logic and Automated Theorem Proving, 2nd edn., Springer 1996 Ben-Ari Mordechai Ben-Ari. Mathematical Logic for Computer Science, Springer, Huth & Ryan Michael Huth and Mark Ryan. Logic in Computer Science, Cambridge University Press, 2nd edn., 2004 André Platzer (CMU) M/08: Data, Code, Decisions 40 / 40

Fundamentals of Software Engineering

Fundamentals of Software Engineering Fundamentals of Software Engineering Reasoning about Programs with Dynamic Logic - Part I Ina Schaefer Institute for Software Systems Engineering TU Braunschweig, Germany Slides by Wolfgang Ahrendt, Richard

More information

Typed First-order Logic

Typed First-order Logic 22c181: Formal Methods in Software Engineering The University of Iowa Spring 2008 Typed First-order Logic Copyright 2007-8 Reiner Hähnle and Cesare Tinelli. Notes originally developed by Reiner Hähnle

More information

Chapter 2 (First-Order Logic) of. Verification of Object-Oriented Software

Chapter 2 (First-Order Logic) of. Verification of Object-Oriented Software Chapter 2 (First-Order Logic) of Verification of Object-Oriented Software The KeY approach c 2007 Springer Verlag 1 First-Order Logic by Martin Giese In this chapter, we introduce a first-order logic.

More information

Overview. CS389L: Automated Logical Reasoning. Lecture 6: First Order Logic Syntax and Semantics. Constants in First-Order Logic.

Overview. CS389L: Automated Logical Reasoning. Lecture 6: First Order Logic Syntax and Semantics. Constants in First-Order Logic. Overview CS389L: Automated Logical Reasoning Lecture 6: First Order Logic Syntax and Semantics Işıl Dillig So far: Automated reasoning in propositional logic. Propositional logic is simple and easy to

More information

From OCL to Typed First-order Logic

From OCL to Typed First-order Logic 22c181: Formal Methods in Software Engineering The University of Iowa Spring 2008 From OCL to Typed First-order Logic Copyright 2007-8 Reiner Hähnle and Cesare Tinelli. Notes originally developed by Reiner

More information

From OCL to Propositional and First-order Logic: Part I

From OCL to Propositional and First-order Logic: Part I 22c181: Formal Methods in Software Engineering The University of Iowa Spring 2008 From OCL to Propositional and First-order Logic: Part I Copyright 2007-8 Reiner Hähnle and Cesare Tinelli. Notes originally

More information

Formal Predicate Calculus. Michael Meyling

Formal Predicate Calculus. Michael Meyling Formal Predicate Calculus Michael Meyling May 24, 2013 2 The source for this document can be found here: http://www.qedeq.org/0_04_07/doc/math/qedeq_formal_logic_v1.xml Copyright by the authors. All rights

More information

A First-Order Logic with First-Class Types

A First-Order Logic with First-Class Types A First-Order Logic with First-Class Types joint work with Peter H. Schmitt and Mattias Ulbrich Institute for Theoretical Computer Science The 8th KeY Symposium, Speyer, 2009 Java Card DL modal logic based

More information

Towards a Logical Reconstruction of Relational Database Theory

Towards a Logical Reconstruction of Relational Database Theory Towards a Logical Reconstruction of Relational Database Theory On Conceptual Modelling, Lecture Notes in Computer Science. 1984 Raymond Reiter Summary by C. Rey November 27, 2008-1 / 63 Foreword DB: 2

More information

Programming Languages Third Edition

Programming Languages Third Edition Programming Languages Third Edition Chapter 12 Formal Semantics Objectives Become familiar with a sample small language for the purpose of semantic specification Understand operational semantics Understand

More information

CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer Science (Arkoudas and Musser) Chapter p. 1/27

CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer Science (Arkoudas and Musser) Chapter p. 1/27 CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer Science (Arkoudas and Musser) Chapter 2.1-2.7 p. 1/27 CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer

More information

Typed Lambda Calculus

Typed Lambda Calculus Department of Linguistics Ohio State University Sept. 8, 2016 The Two Sides of A typed lambda calculus (TLC) can be viewed in two complementary ways: model-theoretically, as a system of notation for functions

More information

Introductory logic and sets for Computer scientists

Introductory logic and sets for Computer scientists Introductory logic and sets for Computer scientists Nimal Nissanke University of Reading ADDISON WESLEY LONGMAN Harlow, England II Reading, Massachusetts Menlo Park, California New York Don Mills, Ontario

More information

This is already grossly inconvenient in present formalisms. Why do we want to make this convenient? GENERAL GOALS

This is already grossly inconvenient in present formalisms. Why do we want to make this convenient? GENERAL GOALS 1 THE FORMALIZATION OF MATHEMATICS by Harvey M. Friedman Ohio State University Department of Mathematics friedman@math.ohio-state.edu www.math.ohio-state.edu/~friedman/ May 21, 1997 Can mathematics be

More information

Automated Reasoning. Natural Deduction in First-Order Logic

Automated Reasoning. Natural Deduction in First-Order Logic Automated Reasoning Natural Deduction in First-Order Logic Jacques Fleuriot Automated Reasoning Lecture 4, page 1 Problem Consider the following problem: Every person has a heart. George Bush is a person.

More information

Typed Lambda Calculus for Syntacticians

Typed Lambda Calculus for Syntacticians Department of Linguistics Ohio State University January 12, 2012 The Two Sides of Typed Lambda Calculus A typed lambda calculus (TLC) can be viewed in two complementary ways: model-theoretically, as a

More information

Foundations of AI. 9. Predicate Logic. Syntax and Semantics, Normal Forms, Herbrand Expansion, Resolution

Foundations of AI. 9. Predicate Logic. Syntax and Semantics, Normal Forms, Herbrand Expansion, Resolution Foundations of AI 9. Predicate Logic Syntax and Semantics, Normal Forms, Herbrand Expansion, Resolution Wolfram Burgard, Andreas Karwath, Bernhard Nebel, and Martin Riedmiller 09/1 Contents Motivation

More information

Higher-Order Logic. Specification and Verification with Higher-Order Logic

Higher-Order Logic. Specification and Verification with Higher-Order Logic Higher-Order Logic Specification and Verification with Higher-Order Logic Arnd Poetzsch-Heffter (Slides by Jens Brandt) Software Technology Group Fachbereich Informatik Technische Universität Kaiserslautern

More information

The Typed λ Calculus and Type Inferencing in ML

The Typed λ Calculus and Type Inferencing in ML Notes on Types S. Arun-Kumar Department of Computer Science and Engineering Indian Institute of Technology New Delhi, 110016 email: sak@cse.iitd.ernet.in April 14, 2002 2 Chapter 1 The Typed λ Calculus

More information

Formal Specification and Verification

Formal Specification and Verification Formal Specification and Verification Introduction to Promela Bernhard Beckert Based on a lecture by Wolfgang Ahrendt and Reiner Hähnle at Chalmers University, Göteborg Formal Specification and Verification:

More information

Module 6. Knowledge Representation and Logic (First Order Logic) Version 2 CSE IIT, Kharagpur

Module 6. Knowledge Representation and Logic (First Order Logic) Version 2 CSE IIT, Kharagpur Module 6 Knowledge Representation and Logic (First Order Logic) 6.1 Instructional Objective Students should understand the advantages of first order logic as a knowledge representation language Students

More information

LOGIC AND DISCRETE MATHEMATICS

LOGIC AND DISCRETE MATHEMATICS LOGIC AND DISCRETE MATHEMATICS A Computer Science Perspective WINFRIED KARL GRASSMANN Department of Computer Science University of Saskatchewan JEAN-PAUL TREMBLAY Department of Computer Science University

More information

Definition: A context-free grammar (CFG) is a 4- tuple. variables = nonterminals, terminals, rules = productions,,

Definition: A context-free grammar (CFG) is a 4- tuple. variables = nonterminals, terminals, rules = productions,, CMPSCI 601: Recall From Last Time Lecture 5 Definition: A context-free grammar (CFG) is a 4- tuple, variables = nonterminals, terminals, rules = productions,,, are all finite. 1 ( ) $ Pumping Lemma for

More information

Part I Logic programming paradigm

Part I Logic programming paradigm Part I Logic programming paradigm 1 Logic programming and pure Prolog 1.1 Introduction 3 1.2 Syntax 4 1.3 The meaning of a program 7 1.4 Computing with equations 9 1.5 Prolog: the first steps 15 1.6 Two

More information

Functional Programming. Pure Functional Programming

Functional Programming. Pure Functional Programming Functional Programming Pure Functional Programming Computation is largely performed by applying functions to values. The value of an expression depends only on the values of its sub-expressions (if any).

More information

Lecture 1: Conjunctive Queries

Lecture 1: Conjunctive Queries CS 784: Foundations of Data Management Spring 2017 Instructor: Paris Koutris Lecture 1: Conjunctive Queries A database schema R is a set of relations: we will typically use the symbols R, S, T,... to denote

More information

1 Introduction. 3 Syntax

1 Introduction. 3 Syntax CS 6110 S18 Lecture 19 Typed λ-calculus 1 Introduction Type checking is a lightweight technique for proving simple properties of programs. Unlike theorem-proving techniques based on axiomatic semantics,

More information

Software Engineering using Formal Methods

Software Engineering using Formal Methods Software Engineering using Formal Methods Introduction to Promela Wolfgang Ahrendt & Richard Bubel & Reiner Hähnle & Wojciech Mostowski 31 August 2011 SEFM: Promela /GU 110831 1 / 35 Towards Model Checking

More information

Chapter 3: Propositional Languages

Chapter 3: Propositional Languages Chapter 3: Propositional Languages We define here a general notion of a propositional language. We show how to obtain, as specific cases, various languages for propositional classical logic and some non-classical

More information

Range Restriction for General Formulas

Range Restriction for General Formulas Range Restriction for General Formulas 1 Range Restriction for General Formulas Stefan Brass Martin-Luther-Universität Halle-Wittenberg Germany Range Restriction for General Formulas 2 Motivation Deductive

More information

A Logic of Proofs for Differential Dynamic Logic

A Logic of Proofs for Differential Dynamic Logic 1 A Logic of Proofs for Differential Dynamic Logic Toward Independently Checkable Proof Certificates for Differential Dynamic Logic Nathan Fulton Andrè Platzer Carnegie Mellon University CPP 16 February

More information

Harvard School of Engineering and Applied Sciences CS 152: Programming Languages

Harvard School of Engineering and Applied Sciences CS 152: Programming Languages Harvard School of Engineering and Applied Sciences CS 152: Programming Languages Lecture 19 Tuesday, April 3, 2018 1 Introduction to axiomatic semantics The idea in axiomatic semantics is to give specifications

More information

Formal Systems and their Applications

Formal Systems and their Applications Formal Systems and their Applications Dave Clarke (Dave.Clarke@cs.kuleuven.be) Acknowledgment: these slides are based in part on slides from Benjamin Pierce and Frank Piessens 1 Course Overview Introduction

More information

Decision Procedures for Recursive Data Structures with Integer Constraints

Decision Procedures for Recursive Data Structures with Integer Constraints Decision Procedures for Recursive Data Structures with Ting Zhang, Henny B Sipma, Zohar Manna Stanford University tingz,sipma,zm@csstanfordedu STeP Group, June 29, 2004 IJCAR 2004 - p 1/31 Outline Outline

More information

CS 512, Spring 2017: Take-Home End-of-Term Examination

CS 512, Spring 2017: Take-Home End-of-Term Examination CS 512, Spring 2017: Take-Home End-of-Term Examination Out: Tuesday, 9 May 2017, 12:00 noon Due: Wednesday, 10 May 2017, by 11:59 am Turn in your solutions electronically, as a single PDF file, by placing

More information

Automata Theory for Reasoning about Actions

Automata Theory for Reasoning about Actions Automata Theory for Reasoning about Actions Eugenia Ternovskaia Department of Computer Science, University of Toronto Toronto, ON, Canada, M5S 3G4 eugenia@cs.toronto.edu Abstract In this paper, we show

More information

Software Engineering Lecture Notes

Software Engineering Lecture Notes Software Engineering Lecture Notes Paul C. Attie August 30, 2013 c Paul C. Attie. All rights reserved. 2 Contents I Hoare Logic 11 1 Propositional Logic 13 1.1 Introduction and Overview..............................

More information

SOFTWARE ENGINEERING DESIGN I

SOFTWARE ENGINEERING DESIGN I 2 SOFTWARE ENGINEERING DESIGN I 3. Schemas and Theories The aim of this course is to learn how to write formal specifications of computer systems, using classical logic. The key descriptional technique

More information

Review Material: First Order Logic (FOL)

Review Material: First Order Logic (FOL) Information Integration on the WEB with RDF, OWL and SPARQL Review Material: First Order Logic (FOL) Grant Weddell October 7, 2013 Syntax of FOL Signatures Vocabularies are called signatures in FOL. The

More information

Applications of Formal Verification

Applications of Formal Verification Applications of Formal Verification Model Checking: Introduction to PROMELA Bernhard Beckert Mattias Ulbrich SS 2017 KIT INSTITUT FÜR THEORETISCHE INFORMATIK KIT University of the State of Baden-Württemberg

More information

Applications of Formal Verification

Applications of Formal Verification Applications of Formal Verification Model Checking: Introduction to PROMELA Prof. Dr. Bernhard Beckert Dr. Vladimir Klebanov SS 2012 KIT INSTITUT FÜR THEORETISCHE INFORMATIK KIT University of the State

More information

Logic as a framework for NL semantics. Outline. Syntax of FOL [1] Semantic Theory Type Theory

Logic as a framework for NL semantics. Outline. Syntax of FOL [1] Semantic Theory Type Theory Logic as a framework for NL semantics Semantic Theory Type Theory Manfred Pinkal Stefan Thater Summer 2007 Approximate NL meaning as truth conditions. Logic supports precise, consistent and controlled

More information

Software Engineering using Formal Methods

Software Engineering using Formal Methods Software Engineering using Formal Methods Introduction to Promela Wolfgang Ahrendt 03 September 2015 SEFM: Promela /GU 150903 1 / 36 Towards Model Checking System Model Promela Program byte n = 0; active

More information

Logic and its Applications

Logic and its Applications Logic and its Applications Edmund Burke and Eric Foxley PRENTICE HALL London New York Toronto Sydney Tokyo Singapore Madrid Mexico City Munich Contents Preface xiii Propositional logic 1 1.1 Informal introduction

More information

A Short Introduction to First-Order Theorem Proving with KeY

A Short Introduction to First-Order Theorem Proving with KeY 1 What is KeY? 1.1 Software Verification Karlsruher Institut für Technologie Institut für Theoretische Informatik Prof. Dr. Peter H. Schmitt Mattias Ulbrich A Short Introduction to First-Order Theorem

More information

Semantics and Pragmatics of NLP Propositional Logic, Predicates and Functions

Semantics and Pragmatics of NLP Propositional Logic, Predicates and Functions , Semantics and Pragmatics of NLP, and s Alex Ewan School of Informatics University of Edinburgh 10 January 2008 , 1 2 3 4 Why Bother?, Aim: 1 To associate NL expressions with semantic representations;

More information

Formal Systems II: Applications

Formal Systems II: Applications Formal Systems II: Applications Functional Verification of Java Programs: Java Dynamic Logic Bernhard Beckert Mattias Ulbrich SS 2017 KIT INSTITUT FÜR THEORETISCHE INFORMATIK KIT University of the State

More information

Classical Planning Problems: Representation Languages

Classical Planning Problems: Representation Languages jonas.kvarnstrom@liu.se 2017 Classical Planning Problems: Representation Languages History: 1959 3 The language of Artificial Intelligence was/is logic First-order, second-order, modal, 1959: General

More information

CSC 501 Semantics of Programming Languages

CSC 501 Semantics of Programming Languages CSC 501 Semantics of Programming Languages Subtitle: An Introduction to Formal Methods. Instructor: Dr. Lutz Hamel Email: hamel@cs.uri.edu Office: Tyler, Rm 251 Books There are no required books in this

More information

First-Order Logic PREDICATE LOGIC. Syntax. Terms

First-Order Logic PREDICATE LOGIC. Syntax. Terms First-Order Logic PREDICATE LOGIC Aim of this lecture: to introduce first-order predicate logic. More expressive than propositional logic. Consider the following argument: all monitors are ready; X12 is

More information

Last class. CS Principles of Programming Languages. Introduction. Outline

Last class. CS Principles of Programming Languages. Introduction. Outline Last class CS6848 - Principles of Programming Languages Principles of Programming Languages V. Krishna Nandivada IIT Madras Interpreters A Environment B Cells C Closures D Recursive environments E Interpreting

More information

Basic Foundations of Isabelle/HOL

Basic Foundations of Isabelle/HOL Basic Foundations of Isabelle/HOL Peter Wullinger May 16th 2007 1 / 29 1 Introduction into Isabelle s HOL Why Type Theory Basic Type Syntax 2 More HOL Typed λ Calculus HOL Rules 3 Example proof 2 / 29

More information

Chapter 2 & 3: Representations & Reasoning Systems (2.2)

Chapter 2 & 3: Representations & Reasoning Systems (2.2) Chapter 2 & 3: A Representation & Reasoning System & Using Definite Knowledge Representations & Reasoning Systems (RRS) (2.2) Simplifying Assumptions of the Initial RRS (2.3) Datalog (2.4) Semantics (2.5)

More information

Constraint Solving. Systems and Internet Infrastructure Security

Constraint Solving. Systems and Internet Infrastructure Security Systems and Internet Infrastructure Security Network and Security Research Center Department of Computer Science and Engineering Pennsylvania State University, University Park PA Constraint Solving Systems

More information

Applications of Formal Verification

Applications of Formal Verification Applications of Formal Verification Model Checking: Introduction to PROMELA Prof. Dr. Bernhard Beckert Dr. Vladimir Klebanov SS 2010 KIT INSTITUT FÜR THEORETISCHE INFORMATIK KIT University of the State

More information

1. true / false By a compiler we mean a program that translates to code that will run natively on some machine.

1. true / false By a compiler we mean a program that translates to code that will run natively on some machine. 1. true / false By a compiler we mean a program that translates to code that will run natively on some machine. 2. true / false ML can be compiled. 3. true / false FORTRAN can reasonably be considered

More information

CMPS 277 Principles of Database Systems. https://courses.soe.ucsc.edu/courses/cmps277/fall11/01. Lecture #3

CMPS 277 Principles of Database Systems. https://courses.soe.ucsc.edu/courses/cmps277/fall11/01. Lecture #3 CMPS 277 Principles of Database Systems https://courses.soe.ucsc.edu/courses/cmps277/fall11/01 Lecture #3 1 Summary of Lectures #1 and #2 Codd s Relational Model based on the concept of a relation (table)

More information

CDM First-Order Logic

CDM First-Order Logic CDM First-Order Logic Klaus Sutner Carnegie Mellon University 40-fol-basics 2017/12/15 23:21 1 First-Order Logic Syntax Model Theory Designing a Logic 3 There are three major parts in the design of a new

More information

logic with quantifiers (informally)

logic with quantifiers (informally) EDAA40 Discrete Structures in Computer Science 8: Quantificational logic Jörn W. Janneck, Dept. of Computer Science, Lund University logic with quantifiers (informally) Given a logical formula that depends

More information

Dynamic Logic with Non-rigid Functions

Dynamic Logic with Non-rigid Functions Dynamic Logic with Non-rigid Functions A Basis for Object-oriented Program Verification Bernhard Beckert 1 André Platzer 2 1 University of Koblenz-Landau, Department of Computer Science beckert@uni-koblenz.de

More information

Lecture 5. Logic I. Statement Logic

Lecture 5. Logic I. Statement Logic Ling 726: Mathematical Linguistics, Logic. Statement Logic V. Borschev and B. Partee, September 27, 2 p. Lecture 5. Logic I. Statement Logic. Statement Logic...... Goals..... Syntax of Statement Logic....2.

More information

Denotational Semantics. Domain Theory

Denotational Semantics. Domain Theory Denotational Semantics and Domain Theory 1 / 51 Outline Denotational Semantics Basic Domain Theory Introduction and history Primitive and lifted domains Sum and product domains Function domains Meaning

More information

Formal Specification and Verification

Formal Specification and Verification Formal Specification and Verification Model Checking with Temporal Logic Bernhard Beckert Based on a lecture by Wolfgang Ahrendt and Reiner Hähnle at Chalmers University, Göteborg Formal Specification

More information

CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer Science (Arkoudas and Musser) Sections p.

CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer Science (Arkoudas and Musser) Sections p. CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer Science (Arkoudas and Musser) Sections 10.1-10.3 p. 1/106 CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer

More information

Z Notation. June 21, 2018

Z Notation. June 21, 2018 Z Notation June 21, 2018 1 Definitions There are many different ways to introduce an object in a Z specification: declarations, abbreviations, axiomatic definitions, and free types. Keep in mind that the

More information

Chapter 3 (part 3) Describing Syntax and Semantics

Chapter 3 (part 3) Describing Syntax and Semantics Chapter 3 (part 3) Describing Syntax and Semantics Chapter 3 Topics Introduction The General Problem of Describing Syntax Formal Methods of Describing Syntax Attribute Grammars Describing the Meanings

More information

Safe Stratified Datalog With Integer Order Does not Have Syntax

Safe Stratified Datalog With Integer Order Does not Have Syntax Safe Stratified Datalog With Integer Order Does not Have Syntax Alexei P. Stolboushkin Department of Mathematics UCLA Los Angeles, CA 90024-1555 aps@math.ucla.edu Michael A. Taitslin Department of Computer

More information

COSC252: Programming Languages: Semantic Specification. Jeremy Bolton, PhD Adjunct Professor

COSC252: Programming Languages: Semantic Specification. Jeremy Bolton, PhD Adjunct Professor COSC252: Programming Languages: Semantic Specification Jeremy Bolton, PhD Adjunct Professor Outline I. What happens after syntactic analysis (parsing)? II. Attribute Grammars: bridging the gap III. Semantic

More information

Lee Pike. June 3, 2005

Lee Pike. June 3, 2005 Proof NASA Langley Formal Methods Group lee.s.pike@nasa.gov June 3, 2005 Proof Proof Quantification Quantified formulas are declared by quantifying free variables in the formula. For example, lem1: LEMMA

More information

Contents. Chapter 1 SPECIFYING SYNTAX 1

Contents. Chapter 1 SPECIFYING SYNTAX 1 Contents Chapter 1 SPECIFYING SYNTAX 1 1.1 GRAMMARS AND BNF 2 Context-Free Grammars 4 Context-Sensitive Grammars 8 Exercises 8 1.2 THE PROGRAMMING LANGUAGE WREN 10 Ambiguity 12 Context Constraints in Wren

More information

The Untyped Lambda Calculus

The Untyped Lambda Calculus Resources: The slides of this lecture were derived from [Järvi], with permission of the original author, by copy & x = 1 let x = 1 in... paste or by selection, annotation, or rewording. [Järvi] is in turn

More information

Propositional Calculus: Boolean Algebra and Simplification. CS 270: Mathematical Foundations of Computer Science Jeremy Johnson

Propositional Calculus: Boolean Algebra and Simplification. CS 270: Mathematical Foundations of Computer Science Jeremy Johnson Propositional Calculus: Boolean Algebra and Simplification CS 270: Mathematical Foundations of Computer Science Jeremy Johnson Propositional Calculus Topics Motivation: Simplifying Conditional Expressions

More information

CSC Discrete Math I, Spring Sets

CSC Discrete Math I, Spring Sets CSC 125 - Discrete Math I, Spring 2017 Sets Sets A set is well-defined, unordered collection of objects The objects in a set are called the elements, or members, of the set A set is said to contain its

More information

CDM First-Order Logic

CDM First-Order Logic CDM First-Order Logic 1 First-Order Logic Klaus Sutner Carnegie Mellon University Syntax 40-fol-basics 2017/12/15 23:21 Model Theory Designing a Logic 3 Digression: Logic, the Field 4 There are three major

More information

Lecture 5 - Axiomatic semantics

Lecture 5 - Axiomatic semantics Program Verification March 2014 Lecture 5 - Axiomatic semantics Lecturer: Noam Rinetzky Scribes by: Nir Hemed 1.1 Axiomatic semantics The development of the theory is contributed to Robert Floyd, C.A.R

More information

Situation Calculus and YAGI

Situation Calculus and YAGI Situation Calculus and YAGI Institute for Software Technology 1 Progression another solution to the projection problem does a sentence hold for a future situation used for automated reasoning and planning

More information

Going beyond propositional logic

Going beyond propositional logic Going beyond propositional logic Consider the following statements: p: Ling took CS245 q: Ling passed CS245 r: Ling failed CS245 Taken literally, these are all atomic statements, and formally they have

More information

Application: Programming Language Semantics

Application: Programming Language Semantics Chapter 8 Application: Programming Language Semantics Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 527 Introduction to Programming Language Semantics Programming Language

More information

Propositional Calculus: Boolean Functions and Expressions. CS 270: Mathematical Foundations of Computer Science Jeremy Johnson

Propositional Calculus: Boolean Functions and Expressions. CS 270: Mathematical Foundations of Computer Science Jeremy Johnson Propositional Calculus: Boolean Functions and Expressions CS 270: Mathematical Foundations of Computer Science Jeremy Johnson Propositional Calculus Objective: To provide students with the concepts and

More information

Software Engineering using Formal Methods

Software Engineering using Formal Methods Software Engineering using Formal Methods Reasoning about Programs with Dynamic Logic Wolfgang Ahrendt & Richard Bubel & Wojciech Mostowski 5 October 2011 SEFM: Java DL /GU 111005 1 / 45 Dynamic Logic

More information

Substitution in Structural Operational Semantics and value-passing process calculi

Substitution in Structural Operational Semantics and value-passing process calculi Substitution in Structural Operational Semantics and value-passing process calculi Sam Staton Computer Laboratory University of Cambridge Abstract Consider a process calculus that allows agents to communicate

More information

CMPSCI 250: Introduction to Computation. Lecture #7: Quantifiers and Languages 6 February 2012

CMPSCI 250: Introduction to Computation. Lecture #7: Quantifiers and Languages 6 February 2012 CMPSCI 250: Introduction to Computation Lecture #7: Quantifiers and Languages 6 February 2012 Quantifiers and Languages Quantifier Definitions Translating Quantifiers Types and the Universe of Discourse

More information

Program Analysis: Lecture 02 Page 1 of 32

Program Analysis: Lecture 02 Page 1 of 32 Program Analysis: Lecture 02 Page 1 of 32 Program Analysis/ Mooly Sagiv Lecture 1, 31/10/2012 Operational Semantics Notes by: Kalev Alpernas As background to the subject of Program Analysis, we will first

More information

Fundamentals of Software Engineering

Fundamentals of Software Engineering Fundamentals of Software Engineering Reasoning about Programs with Dynamic Logic - Part II Ina Schaefer Institute for Software Systems Engineering TU Braunschweig, Germany Slides by Wolfgang Ahrendt, Richard

More information

Propositional Logic. Part I

Propositional Logic. Part I Part I Propositional Logic 1 Classical Logic and the Material Conditional 1.1 Introduction 1.1.1 The first purpose of this chapter is to review classical propositional logic, including semantic tableaux.

More information

Warm-Up Problem. Let L be the language consisting of as constant symbols, as a function symbol and as a predicate symbol. Give an interpretation where

Warm-Up Problem. Let L be the language consisting of as constant symbols, as a function symbol and as a predicate symbol. Give an interpretation where Warm-Up Problem Let L be the language consisting of as constant symbols, as a function symbol and as a predicate symbol Give an interpretation where is false Use a finite domain in your interpretation

More information

F. Brief review of classical predicate logic (PC)

F. Brief review of classical predicate logic (PC) F. Brief review of classical predicate logic (PC) F.I. Syntax (LfP 4.1) F.I.1. Primitive symbols Primitive vocabulary of PC (LfP 90): connectives: Ñ,, @ variables: x, y,... (with or without numerical subscripts)

More information

Computer Science Technical Report

Computer Science Technical Report Computer Science Technical Report Feasibility of Stepwise Addition of Multitolerance to High Atomicity Programs Ali Ebnenasir and Sandeep S. Kulkarni Michigan Technological University Computer Science

More information

Proseminar on Semantic Theory Fall 2013 Ling 720 An Algebraic Perspective on the Syntax of First Order Logic (Without Quantification) 1

Proseminar on Semantic Theory Fall 2013 Ling 720 An Algebraic Perspective on the Syntax of First Order Logic (Without Quantification) 1 An Algebraic Perspective on the Syntax of First Order Logic (Without Quantification) 1 1. Statement of the Problem, Outline of the Solution to Come (1) The Key Problem There is much to recommend an algebraic

More information

Structure of Abstract Syntax trees for Colored Nets in PNML

Structure of Abstract Syntax trees for Colored Nets in PNML Structure of Abstract Syntax trees for Colored Nets in PNML F. Kordon & L. Petrucci Fabrice.Kordon@lip6.fr Laure.Petrucci@lipn.univ-paris13.fr version 0.2 (draft) June 26, 2004 Abstract Formalising the

More information

Propositional Logic Formal Syntax and Semantics. Computability and Logic

Propositional Logic Formal Syntax and Semantics. Computability and Logic Propositional Logic Formal Syntax and Semantics Computability and Logic Syntax and Semantics Syntax: The study of how expressions are structured (think: grammar) Semantics: The study of the relationship

More information

3.7 Denotational Semantics

3.7 Denotational Semantics 3.7 Denotational Semantics Denotational semantics, also known as fixed-point semantics, associates to each programming language construct a well-defined and rigorously understood mathematical object. These

More information

Alloy: A Lightweight Object Modelling Notation

Alloy: A Lightweight Object Modelling Notation Alloy: A Lightweight Object Modelling Notation Daniel Jackson, ACM Transactions on Software Engineering, 2002 Presented By: Steven Stewart, 2012-January-23 1 Alloy: 2002 to present Software is built on

More information

Propositional Calculus. CS 270: Mathematical Foundations of Computer Science Jeremy Johnson

Propositional Calculus. CS 270: Mathematical Foundations of Computer Science Jeremy Johnson Propositional Calculus CS 270: Mathematical Foundations of Computer Science Jeremy Johnson Propositional Calculus Objective: To provide students with the concepts and techniques from propositional calculus

More information

3.4 Deduction and Evaluation: Tools Conditional-Equational Logic

3.4 Deduction and Evaluation: Tools Conditional-Equational Logic 3.4 Deduction and Evaluation: Tools 3.4.1 Conditional-Equational Logic The general definition of a formal specification from above was based on the existence of a precisely defined semantics for the syntax

More information

Note that in this definition, n + m denotes the syntactic expression with three symbols n, +, and m, not to the number that is the sum of n and m.

Note that in this definition, n + m denotes the syntactic expression with three symbols n, +, and m, not to the number that is the sum of n and m. CS 6110 S18 Lecture 8 Structural Operational Semantics and IMP Today we introduce a very simple imperative language, IMP, along with two systems of rules for evaluation called small-step and big-step semantics.

More information

CS 242. Fundamentals. Reading: See last slide

CS 242. Fundamentals. Reading: See last slide CS 242 Fundamentals Reading: See last slide Syntax and Semantics of Programs Syntax The symbols used to write a program Semantics The actions that occur when a program is executed Programming language

More information

Theorem proving. PVS theorem prover. Hoare style verification PVS. More on embeddings. What if. Abhik Roychoudhury CS 6214

Theorem proving. PVS theorem prover. Hoare style verification PVS. More on embeddings. What if. Abhik Roychoudhury CS 6214 Theorem proving PVS theorem prover Abhik Roychoudhury National University of Singapore Both specification and implementation can be formalized in a suitable logic. Proof rules for proving statements in

More information

Fall Lecture 3 September 4. Stephen Brookes

Fall Lecture 3 September 4. Stephen Brookes 15-150 Fall 2018 Lecture 3 September 4 Stephen Brookes Today A brief remark about equality types Using patterns Specifying what a function does equality in ML e1 = e2 Only for expressions whose type is

More information

Term Algebras with Length Function and Bounded Quantifier Elimination

Term Algebras with Length Function and Bounded Quantifier Elimination with Length Function and Bounded Ting Zhang, Henny B Sipma, Zohar Manna Stanford University tingz,sipma,zm@csstanfordedu STeP Group, September 3, 2004 TPHOLs 2004 - p 1/37 Motivation: Program Verification

More information