Predicate’ is the name given to the word occurring before the bracket in a fact or rule: parent(jane,alan).
By defining a predicate you are specifying which information needs to be known for the property denoted by the predicate to be true.
power of two is a function in prolog that is use to fine 2n value here (K,P) where K being the n value of two power and being the value saver.
the poweoftwo will calulate 2n value
(b) Define the PROLOG predicate poweroftwo(K,P) 2 where K is a natural number to calculate P...
PROLOG: Write a prolog predicate that counts occurrences of 'x', 'y', or 'z' in a list. For example, count([x,[y,[a,2],[a,3]],[a,4]], 2) should return true. I only want to count occurrences of x,y,z not a. the base case is that any [a,int] list will have a count of 0. So any sublist with 'a' does not count. another example of what will return true is: count([x,[a,1],[a,5]], 1) The predicate must have the form count(X,Y) where X is the list structure passed and...
In Prolog, define the isUnion predicate so that isUnion(X,Y,Z) says that the union of X and Y is Z. Do not use the predefined list predicates. Your predicate may choose a fixed order for Z. If you query isUnion([1,2],[3],Z) it should find a binding for Z, but it need not succeed on both isUnion([1],[2],[1,2]) and isUnion([1],[2],[2,1]). Your predicate need not work well when X or Y are unbound variables.
Code in Prolog a predicate swapFirstTwo/2 that swaps the rst two elements of the given list. If the list is too short, it must fail. ?- swapFirstTwo([a,b,c,d,e], Ys). Ys = [b,a,c,d,e]. ?- swapFirstTwo([a], Ys). false.
Consider the interface Predicate defined as follows. interface Predicate { boolean eval(int j); } Recall that you can check if an integer “i” is even by using the expression “i%2 == 0”. Write a class IsEven that determines whether a number is even: class IsEven implements Predicate { public boolean eval(int j) { } } For example, the following code Predicate p = new IsEven(); if ( p.eval(2)) { System.out.println("2 is even"); } if (! p.eval(3)) { System.out.println("3 is not...
Select the correct PROLOG definition of powerof2/2, where powerof2(K,N) checks whether N is equal to 2K (A) powerof2(0,1);- !. powerof2(K,P):- K1 is K-1, powerof2(K1,P1), P is P1*K. (B) (C) powerof2(0,1);- !. powerof2(K,P);- powerof2(K1,P1), K1 is K-1, P is P1*2. powerof2(0,1):- !. powerof2(K,P):- powerof2(K,P), P is P1*2. powerof2(0,1);- !. powerof2(K,P):- K1 is K-1, powerof2(K1,P1), P is P1*2. (D) CA (B) (C) D
8 marks] Number representations. We define the predicate BT(n,): "r has a balanced ternary represen tation that contains n digits," where n eZ+ and z e Z. Equivalently BT(n,z) : 34, di, ,dn-le(-1,0,1), Σdi.gi=z Prove the following statement using induction on n 3a-1
8 marks] Number representations. We define the predicate BT(n,): "r has a balanced ternary represen tation that contains n digits," where n eZ+ and z e Z. Equivalently BT(n,z) : 34, di, ,dn-le(-1,0,1), Σdi.gi=z Prove the following...
K = 4
Let X → Geometric (p) where p such that P (X > n) =t. and k is number of letters in your j
Let X → Geometric (p) where p such that P (X > n) =t. and k is number of letters in your j
Question 2 2A. Define Reynolds number. 2B. What is the range of Reynolds number where the Darcy's Law is applicable? 2C. How should you ensure you are in the valid range of Reynolds number to apply the Darcy's Law correctly? 2D. Consider a porous medium with the following rock properties • Porosity, Ø = 20% • Permeability, k = 200 mD The fluid being injected into the medium at a Darcian velocity, u = 5 cm/s, has the following properties...
Show that there are infinitely many primes of the form p=4k+3, k is a natural number. Hint: argue by contradiction: if there are finitely many such primes p1=3, p2=7,...,pn, consider the number N=4(p1,p2,...,pn) + 3.
1. Define: phylogeny 2. Describe natural selection and give an example of natural selection at work in a population over time. 3. Why are vestigial structures considered to be evidence for evolution? 4. What are some other types of things cited as evidence for evolution? 5. What is the difference between microevolution and macroevolution?