COMP2111 1 2020 Term 1

Java Python COMP2111

Assignment 1

2020 Term 1

Due: Thu, 19th March, 12:00 noon

Problem 1 (20 marks)

Recall the relation composition operator ; defined as:

R1; R2 = {(a, c) | there is a b with (a, b) ∈ R1 and (b, c) ∈ R2}

For any set S, and any binary relations R1, R2, R3 ⊆ S × S, prove or give a counterexample to disprove the following:

(a) (R1; R2); R3 = R1;(R2; R3)                                                       (4 marks)

(b) I; R1 = R1; I = R1 where I = {(x, x) | x ∈ S}                             (4 marks)

(c) (R1; R2)← = R1 ←; R2 ←                                                         (4 marks)

(d) (R1 ∪ R2); R3 = (R1; R3) ∪ (R2; R3)                                        (4 marks)

(e) R1;(R2 ∩ R3) = (R1; R2) ∩ (R1; R3)                                           (4 marks)

Problem 2 (30 marks)

Let R ⊆ S × S be any binary relation on a set S. Consider the sequence of relations R 0 , R 1 , R 2 , . . ., defined as follows:

R0 := I = {(x, x) | x ∈ S}, and

Ri+1 := Ri ∪ (R; Ri) for i ≥ 0

(a) Prove that if there is an i such that R i = R i+1 , then R j = R i for all j ≥ i. (4 marks)

(b) Prove that if there is an i such that R i = R i+1 , then R k ⊆ R i for all k ≥ 0. (4 marks)

(c) Let P(n) be the proposition that for all m ∈ N: R n ; R m = R n+m. Prove that P(n) holds for all n ∈ N. (8 marks)

(d) If |S| = k, explain why R k = R k+1 . (Hint: Show that if (a, b) ∈ R k+1 then (a, b) ∈ R i for some i < k + 1.) (4 marks)

(e) If |S| = k, show that R k is transitive. (4 marks)

(f) If |S| = k, show that (R ∪ R←) k is an equivalence relation. (6 marks)

Problem 3 (22 marks)

Let PF denote the set of well-formed propositional formulae made up of propositional variables, > , ⊥, and the connectives ¬, ∧, and ∨.

We define the function dual(ϕ) from PF to PF, which swaps ∧ and ∨, as well as > with ⊥. We also define flip(ϕ) from PF to PF, which negates adai 写COMP2111 Assignment 1 2020 Term 1 ny propositional variables in the formula:

dual(p) = p                                             flip(p) = ¬p

dual(> ) = ⊥                                          flip(> ) = >

dual(⊥) = >                                           flip(⊥) = ⊥

dual(¬ϕ) = ¬ dual(ϕ)                               flip(¬ϕ) = ¬flip(ϕ)

dual(ϕ ∧ ψ) = dual(ϕ) ∨ dual(ψ)               flip(ϕ ∧ ψ) = flip(ϕ) ∧ flip(ψ)

dual(ϕ ∨ ψ) = dual(ϕ) ∧ dual(ψ)               flip(ϕ ∨ ψ) = flip(ϕ) ∨ flip(ψ)

(a) For the formula ϕ = p ∨ (q ∧ ¬r):

(i) What is dual(ϕ)? (4 marks)

(ii) What is flip(ϕ)? (4 marks)

(b) Prove that for all ϕ ∈ PF: flip(ϕ) is logically equivalent to ¬dual(ϕ). (14 marks)

Problem 4 (28 marks)

Four wifi networks, Alpha, Bravo, Charlie and Delta, all exist within close proximity to one another as shown below.

Networks connected with an edge in the diagram above can interfere with each other. To avoid interference networks can operate on one of two channels, hi and lo. Networks operating on different channels will not interfere; and neither will networks that are not connected with an edge.

Our goal is to determine (algorithmically) whether there is an assignment of channels to networks so that there is no interference. To do this we will transform. the problem into a problem of determining if a propositional formula can be satisfied.

(a) Carefully defining the propositional variables you are using, write propositional formulae for each of the following requirements:                     (4 marks)

(i) ϕ1: Alpha uses channel hi or channel lo; and so does Bravo, Charlie and Delta. (4 marks)

(ii) ϕ2: Alpha does not use both channel hi and lo; and the same for Bravo, Charlie and Delta.(4 marks)

(iii) ϕ3: Alpha and Bravo do not use the same channel; and the same applies for all other pairs of networks connected with an edge. (4 marks)

(b) (i) Show that ϕ1 ∧ ϕ2 ∧ ϕ3 is satisfiable; so the requirements can all be met. Note that it is sufficient to give a satisfying truth assignment, you do not have to list all possible combinations         

### 在 Simulink 中实现带有指数函数的复杂数学公式计算模块 在 Simulink 中,可以使用 `Math Function` 模块来实现指数函数 `exp` 的计算[^1]。此外,结合其他数学运算模块(如 `Sum`、`Product` 和 `Gain`),可以构建复杂的数学公式。 以下是一个详细的实现方案,展示如何在 Simulink 中实现一个包含指数函数的复杂公式: #### 示例:实现公式 \( y = a \cdot e^{b \cdot x} + c \) 1. **添加必要的模块**: - 使用 `Math Function` 模块设置为 `exp`,以实现指数函数。 - 使用 `Product` 模块进行乘法运算。 - 使用 `Sum` 模块进行加法运算。 - 使用 `Constant` 模块定义常数 \(a\)、\(b\) 和 \(c\)。 - 使用 `Gain` 模块对输入信号 \(x\) 进行缩放。 2. **模型搭建步骤**: 下面是实现该公式的具体代码示例: ```matlab % 创建一个新的 Simulink 模型 new_system('ExponentialFormulaModel'); % 添加模块 add_block('simulink/Math Operations/Math Function', 'ExponentialFormulaModel/Exp'); add_block('simulink/Math Operations/Product', 'ExponentialFormulaModel/Product_1'); add_block('simulink/Math Operations/Product', 'ExponentialFormulaModel/Product_2'); add_block('simulink/Math Operations/Sum', 'ExponentialFormulaModel/Sum'); add_block('simulink/Sources/Constant', 'ExponentialFormulaModel/Constant_a'); add_block('simulink/Sources/Constant', 'ExponentialFormulaModel/Constant_b'); add_block('simulink/Sources/Constant', 'ExponentialFormulaModel/Constant_c'); add_block('simulink/Math Operations/Gain', 'ExponentialFormulaModel/Gain'); % 设置模块参数 set_param('ExponentialFormulaModel/Exp', 'Operator', 'exp'); % 设置为指数函数 set_param('ExponentialFormulaModel/Constant_a', 'Value', 'a'); % 常数 a set_param('ExponentialFormulaModel/Constant_b', 'Value', 'b'); % 常数 b set_param('ExponentialFormulaModel/Constant_c', 'Value', 'c'); % 常数 c set_param('ExponentialFormulaModel/Gain', 'Gain', 'b'); % 缩放因子 b % 连接模块 add_line('ExponentialFormulaModel', 'Gain/1', 'Exp/1'); % b * x 输入到 exp add_line('ExponentialFormulaModel', 'Constant_a/1', 'Product_1/1'); % a 输入到乘法器 add_line('ExponentialFormulaModel', 'Exp/1', 'Product_1/2'); % exp(b * x) 输入到乘法器 add_line('ExponentialFormulaModel', 'Product_1/1', 'Sum/1'); % a * exp(b * x) 输入到加法器 add_line('ExponentialFormulaModel', 'Constant_c/1', 'Sum/2'); % c 输入到加法器 ``` 3. **模块功能说明**: - `Math Function` 模块设置为 `exp`,用于计算指数函数 \(e^{b \cdot x}\)。 - `Product` 模块用于将常数 \(a\) 与指数函数的结果相乘。 - `Sum` 模块用于将乘积结果与常数 \(c\) 相加。 - `Gain` 模块用于对输入信号 \(x\) 进行缩放,实现 \(b \cdot x\) 的计算。 4. **运行仿真**: 配置输入信号 \(x\)(例如使用 `Sine Wave` 或 `Step` 模块),然后运行仿真以观察输出 \(y\) 的变化。 #### 注意事项 - 确保所有常数值(如 \(a\)、\(b\) 和 \(c\))正确设置。 - 如果公式中包含更复杂的数学运算,可以结合 `Fcn` 模块或 MATLAB Function 模块实现自定义函数[^1]。 ---
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值