basicproofs - //Statement 2: //if x, y, z satisfy the...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
public class basicproofs { //@ requires (x>0); //@ ensures (x>=1); public void demoproof(int x) { //For all integers x, if x > 0 then x >= 1 } //@ requires ((x+y)>z & (x+z)>y && (y+z)>x); public void proof1(int x, int y, int z) { //Statement 1: //if x, y, z satisfy the triangle inequalities then x, y, z are positive } //@ requires ((x+y)>z & (x+z)>y && (y+z)>x); //@ ensures (x > Math.abs(y-z) & y > Math.abs(x-z) && z > Math.abs(y-x)); public void proof2(int x, int y, int z) {
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: //Statement 2: //if x, y, z satisfy the triangle inequality then each side is //larger than the absolute difference of the other two sides //Hint: Use the Java function Math.abs() to compute absolute values } //@ requires (x > Math.abs(y-z) && y > Math.abs(x-z) && z > Math.abs(y-x)); //@ ensures ((x+y)>z && (x+z)>y && (y+z)>x); public void proof3(int x, int y, int z) { //Is the converse of Statement 2 true? Try and find out! } }...
View Full Document

This note was uploaded on 10/03/2010 for the course CS cs196 taught by Professor Kumar during the Fall '10 term at University of Illinois, Urbana Champaign.

Ask a homework question - tutors are online